From 1d5853c2cb15dffd045996df83eb10e0815dfec4 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Fri, 13 May 2016 17:19:48 +0200 Subject: [PATCH] better behavior for wheel zoom --- mobile/components/DocumentView.qml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/mobile/components/DocumentView.qml b/mobile/components/DocumentView.qml index 148ef059a..b7735e28b 100644 --- a/mobile/components/DocumentView.qml +++ b/mobile/components/DocumentView.qml @@ -155,8 +155,19 @@ QtControls.ScrollView { } onWheel: { if (wheel.modifiers & Qt.ControlModifier) { - var factor = (wheel.angleDelta.y / 120) * 1.2; - flick.resizeContent(flick.contentWidth * factor, flick.contentHeight * factor, Qt.point(wheel.x, wheel.y)); + //generate factors between 0.8 and 1.2 + var factor = (((wheel.angleDelta.y / 120)+1) / 5 )+ 0.8; + + var newWidth = flick.contentWidth * factor; + var newHeight = flick.contentHeight * factor; + + if (newWidth < flick.width || newHeight < flick.height || + newHeight > flick.height * 3) { + return; + } + + flick.resizeContent(newWidth, newHeight, Qt.point(wheel.x, wheel.y)); + flick.returnToBounds(); resizeTimer.stop(); } else { flick.contentY = Math.min(flick.contentHeight-flick.height, Math.max(0, flick.contentY - wheel.angleDelta.y));