on xenial help sign in
fix jumping when changing swipe direction
0379a84Michael Zanetti
qml/Stages/SpreadDelegate.qml+10−1
@@ -76,6 +76,7 @@ Item {
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)
78 readonly property int threshold: units.gu(2)
79+ property int offset: 0
79
80
80 readonly property real minSpeedToClose: units.gu(40)
81 readonly property real minSpeedToClose: units.gu(40)
81
82
@@ -85,7 +86,15 @@ Item {
85 }
86 }
86 moving = moving || Math.abs(dragValue) > threshold;
87 moving = moving || Math.abs(dragValue) > threshold;
87 if (moving) {
88 if (moving) {
89+ distance = dragValue + offset;
90+ }
91+ }
92+
93+ onMovingChanged: {
94+ if (moving) {
88− distance = dragValue + (dragValue > 0 ? -threshold: threshold);
95+ offset = (dragValue > 0 ? -threshold: threshold)
96+ } else {
97+ offset = 0;
89 }
98 }
90 }
99 }
91
100
tests/qmltests/Stages/tst_SpreadDelegate.qml+4−3
@@ -137,9 +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
140− // Verify that the delegate started moving exactly 2 gus after the finger movement
141+ // Verify that the delegate started moving exactly "threshold" after the finger movement
141− // and did not jump up to the finger, but lags those 2 gus behind
142+ // and did not jump up to the finger, but lags the threshold behind
142− verify(Math.abs(Math.abs(appWindowWithShadow.y) - dragDistance) == units.gu(2));
143+ verify(Math.abs(Math.abs(appWindowWithShadow.y) - dragDistance) == threshold);
143
144
144 touchRelease(spreadDelegateLoader.item, touchX, toY - units.gu(1));
145 touchRelease(spreadDelegateLoader.item, touchX, toY - units.gu(1));
145
146