on xenial help sign in
increase threshold and avoid jumping in SpreadDelegate dragging Fixes: #1350803, #1352842

Approved by: Albert Astals Cid

commit24b1822d41375761182941f0c26c7080826602ee authorMichael Zanetti <michael.zanetti@canonical.com> dateTue 25 Nov 2014, 13:53 (12 years ago) parent7c4a08b217ad72
2 files changed+16−3
qml/Stages/SpreadDelegate.qml+12−2 tests/qmltests/Stages/tst_SpreadDelegate.qml+4−1
qml/Stages/SpreadDelegate.qml+12−2
@@ -75,6 +75,8 @@ Item {
7575
7676 property bool moving: false
7777 property real distance: 0
78+ readonly property int threshold: units.gu(2)
79+ property int offset: 0
7880
7981 readonly property real minSpeedToClose: units.gu(40)
8082
@@ -82,9 +84,17 @@ Item {
8284 if (!dragging) {
8385 return;
8486 }
85− moving = moving || Math.abs(dragValue) > units.gu(1)
87+ moving = moving || Math.abs(dragValue) > threshold;
8688 if (moving) {
87− distance = dragValue;
89+ distance = dragValue + offset;
90+ }
91+ }
92+
93+ onMovingChanged: {
94+ if (moving) {
95+ offset = (dragValue > 0 ? -threshold: threshold)
96+ } else {
97+ offset = 0;
8898 }
8999 }
90100
tests/qmltests/Stages/tst_SpreadDelegate.qml+4−1
@@ -137,7 +137,10 @@ Rectangle {
137137
138138 if (data.swipeToClose) {
139139 verify(appWindowWithShadow.y < 0);
140− verify(Math.abs(Math.abs(appWindowWithShadow.y) - dragDistance) < units.gu(1));
140+ var threshold = findChild(spreadDelegateLoader.item, "dragArea").threshold
141+ // Verify that the delegate started moving exactly "threshold" after the finger movement
142+ // and did not jump up to the finger, but lags the threshold behind
143+ compare(Math.abs(Math.abs(appWindowWithShadow.y) - dragDistance), threshold);
141144
142145 touchRelease(spreadDelegateLoader.item, touchX, toY - units.gu(1));
143146