on xenial help sign in
increase threshold and avoid jumping in SpreadDelegate dragging Fixes: #1350803, #1352842
24b1822Michael Zanetti
qml/Stages/SpreadDelegate.qml+12−2
@@ -75,6 +75,8 @@ Item {
75
75
76 property bool moving: false
76 property bool moving: false
77 property real distance: 0
77 property real distance: 0
78+ readonly property int threshold: units.gu(2)
79+ property int offset: 0
78
80
79 readonly property real minSpeedToClose: units.gu(40)
81 readonly property real minSpeedToClose: units.gu(40)
80
82
@@ -82,9 +84,17 @@ Item {
82 if (!dragging) {
84 if (!dragging) {
83 return;
85 return;
84 }
86 }
85− moving = moving || Math.abs(dragValue) > units.gu(1)
87+ moving = moving || Math.abs(dragValue) > threshold;
86 if (moving) {
88 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;
88 }
98 }
89 }
99 }
90
100
tests/qmltests/Stages/tst_SpreadDelegate.qml+4−1
@@ -137,7 +137,10 @@ Rectangle {
137
137
138 if (data.swipeToClose) {
138 if (data.swipeToClose) {
139 verify(appWindowWithShadow.y < 0);
139 verify(appWindowWithShadow.y < 0);
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
140− verify(Math.abs(Math.abs(appWindowWithShadow.y) - dragDistance) < units.gu(1));
143+ compare(Math.abs(Math.abs(appWindowWithShadow.y) - dragDistance), threshold);
141
144
142 touchRelease(spreadDelegateLoader.item, touchX, toY - units.gu(1));
145 touchRelease(spreadDelegateLoader.item, touchX, toY - units.gu(1));
143
146