on xenial help sign in
fix jumping when changing swipe direction
commit0379a84eaed0ed92ed1031bee0416e668d22cb5e authorMichael Zanetti <michael.zanetti@canonical.com> dateThu 20 Nov 2014, 14:02 (12 years ago) parent027df6b
2 files changed+14−4
qml/Stages/SpreadDelegate.qml+10−1 tests/qmltests/Stages/tst_SpreadDelegate.qml+4−3
qml/Stages/SpreadDelegate.qml+10−1
@@ -76,6 +76,7 @@ Item {
7676 property bool moving: false
7777 property real distance: 0
7878 readonly property int threshold: units.gu(2)
79+ property int offset: 0
7980
8081 readonly property real minSpeedToClose: units.gu(40)
8182
@@ -85,7 +86,15 @@ Item {
8586 }
8687 moving = moving || Math.abs(dragValue) > threshold;
8788 if (moving) {
88− distance = dragValue + (dragValue > 0 ? -threshold: threshold);
89+ distance = dragValue + offset;
90+ }
91+ }
92+
93+ onMovingChanged: {
94+ if (moving) {
95+ offset = (dragValue > 0 ? -threshold: threshold)
96+ } else {
97+ offset = 0;
8998 }
9099 }
91100
tests/qmltests/Stages/tst_SpreadDelegate.qml+4−3
@@ -137,9 +137,10 @@ Rectangle {
137137
138138 if (data.swipeToClose) {
139139 verify(appWindowWithShadow.y < 0);
140− // Verify that the delegate started moving exactly 2 gus after the finger movement
141− // and did not jump up to the finger, but lags those 2 gus behind
142− verify(Math.abs(Math.abs(appWindowWithShadow.y) - dragDistance) == units.gu(2));
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+ verify(Math.abs(Math.abs(appWindowWithShadow.y) - dragDistance) == threshold);
143144
144145 touchRelease(spreadDelegateLoader.item, touchX, toY - units.gu(1));
145146