on xenial help sign in
add a threshold vor up/down drag in spread
commit4f47a9c5c60a2f37c9645b7eb352978ce888b3cc authorMichael Zanetti <michael.zanetti@canonical.com> dateWed 24 Aug 2016, 17:41 (10 years ago) parent428e006
1 file changed+17−12
qml/Stage/Spread/SpreadDelegateInputArea.qml+17−12
qml/Stage/Spread/SpreadDelegateInputArea.qml+17−12
@@ -22,6 +22,7 @@ Item {
2222 property bool moving: false
2323 property var dragEvents: []
2424 property real dragVelocity: 0
25+ property int threshold: units.gu(2)
2526
2627 // Can be replaced with a fake implementation during tests
2728 // property var __getCurrentTimeMs: function () { return new Date().getTime() }
@@ -80,14 +81,13 @@ Item {
8081 anchors.fill: parent
8182 mouseEnabled: false
8283 maximumTouchPoints: 1
84+ property int offset: 0
8385
84− onGestureStarted: {
85− if (!d.moving) {
86− d.moving = true
87− gesture.grab();
88− d.dragEvents = []
86+ touchPoints: [
87+ TouchPoint {
88+ id: tp
8989 }
90− }
90+ ]
9191
9292 onCanceled: {
9393 d.moving = false
@@ -95,14 +95,19 @@ Item {
9595 }
9696
9797 onTouchUpdated: {
98− if (touchPoints.length == 0 || !d.moving) {
99− return;
98+ if (!d.moving) {
99+ if (Math.abs(tp.startY - tp.y) > d.threshold) {
100+ d.moving = true;
101+ d.dragEvents = []
102+ offset = tp.y - tp.startY;
103+ } else {
104+ return;
105+ }
100106 }
101107
102− var touchPoint = touchPoints[0];
103− d.distance = touchPoint.y - touchPoint.startY
104− d.pushDragEvent(touchPoint);
105− print("pushed event", touchPoint.y, "velocity is now", d.dragVelocity)
108+ d.distance = tp.y - tp.startY - offset
109+ d.pushDragEvent(tp);
110+ print("pushed event", tp.y, "velocity is now", d.dragVelocity)
106111 }
107112
108113 onReleased: {