diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-09-06 12:25:38 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-09-06 12:28:19 +0200 |
commit | 7bbaf70ad2e7b51c935d12408ec56d0c9ae28382 (patch) | |
tree | 6351eafe69481edcc4565984d7b88b658a284b0e /framework/qml/ScrollHelper.qml | |
parent | 323dae6c7fd982f444e1736410888037239e662c (diff) | |
download | kube-7bbaf70ad2e7b51c935d12408ec56d0c9ae28382.tar.gz kube-7bbaf70ad2e7b51c935d12408ec56d0c9ae28382.zip |
Improved mouse wheel scrolling.
Scrolling with a mouse (instead of a trackpad) was too slow. This
improves that.
Diffstat (limited to 'framework/qml/ScrollHelper.qml')
-rw-r--r-- | framework/qml/ScrollHelper.qml | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/framework/qml/ScrollHelper.qml b/framework/qml/ScrollHelper.qml index 76bcca47..b8533a9c 100644 --- a/framework/qml/ScrollHelper.qml +++ b/framework/qml/ScrollHelper.qml | |||
@@ -54,10 +54,18 @@ MouseArea { | |||
54 | return flickableItem.contentY; | 54 | return flickableItem.contentY; |
55 | } | 55 | } |
56 | //pixelDelta seems to be the same as angleDelta/8 | 56 | //pixelDelta seems to be the same as angleDelta/8 |
57 | var pixelDelta = wheel.pixelDelta.y != 0 ? wheel.pixelDelta.y : wheel.angleDelta.y / 8 | 57 | var pixelDelta = 0 |
58 | //The pixelDelta is a smaller number if both are provided, so pixelDelta can be 0 while angleDelta is still something. So we check the angleDelta | ||
59 | if (wheel.angleDelta.y) { | ||
60 | var wheelScrollLines = 3 //Default value of QApplication wheelScrollLines property | ||
61 | var pixelPerLine = 20 //Default value in Qt, originally comes from QTextEdit | ||
62 | var ticks = (wheel.angleDelta.y / 8) / 15.0 //Divide by 8 gives us pixels typically come in 15pixel steps. | ||
63 | pixelDelta = ticks * pixelPerLine * wheelScrollLines | ||
64 | } else { | ||
65 | pixelDelta = wheel.pixelDelta.y | ||
66 | } | ||
58 | 67 | ||
59 | var y = pixelDelta | 68 | if (!pixelDelta) { |
60 | if (!y) { | ||
61 | return flickableItem.contentY; | 69 | return flickableItem.contentY; |
62 | } | 70 | } |
63 | 71 | ||
@@ -69,7 +77,7 @@ MouseArea { | |||
69 | } | 77 | } |
70 | 78 | ||
71 | //Avoid overscrolling | 79 | //Avoid overscrolling |
72 | return Math.max(minYExtent, Math.min(maxYExtent, flickableItem.contentY - y)); | 80 | return Math.max(minYExtent, Math.min(maxYExtent, flickableItem.contentY - pixelDelta)); |
73 | } | 81 | } |
74 | 82 | ||
75 | onWheel: { | 83 | onWheel: { |