on xenial help sign in
Fix DragHandle
91c46b9Albert Astals Cid
qml/Components/DragHandle.qml+11−14
@@ -118,26 +118,26 @@ SwipeArea {
118 }
118 }
119 }
119 }
120
120
121− function limitMovement(inputStep) {
121+ function limitMovement(distance) {
122− var targetValue = MathUtils.clamp(dragParent[targetProp] + inputStep, minValue, maxValue);
122+ var targetValue = MathUtils.clamp(d.startValue + distance, minValue, maxValue);
123− var step = targetValue - dragParent[targetProp];
123+ var diff = targetValue - d.startValue;
124
124
125 if (hintDisplacement == 0) {
125 if (hintDisplacement == 0) {
126− return step;
126+ return diff;
127 }
127 }
128
128
129 // we should not go behind hintingAnimation's current value
129 // we should not go behind hintingAnimation's current value
130 if (Direction.isPositive(direction)) {
130 if (Direction.isPositive(direction)) {
131− if (dragParent[targetProp] + step < hintingAnimation.targetValue) {
131+ if (d.startValue + diff < hintingAnimation.targetValue) {
132− step = hintingAnimation.targetValue - dragParent[targetProp];
132+ diff = hintingAnimation.targetValue - d.startValue;
133 }
133 }
134 } else {
134 } else {
135− if (dragParent[targetProp] + step > hintingAnimation.targetValue) {
135+ if (d.startValue + diff > hintingAnimation.targetValue) {
136− step = hintingAnimation.targetValue - dragParent[targetProp];
136+ diff = hintingAnimation.targetValue - d.startValue;
137 }
137 }
138 }
138 }
139
139
140− return step;
140+ return diff;
141 }
141 }
142
142
143 function onFinishedRecognizedGesture() {
143 function onFinishedRecognizedGesture() {
@@ -179,11 +179,8 @@ SwipeArea {
179 onDistanceChanged: {
179 onDistanceChanged: {
180 if (dragging) {
180 if (dragging) {
181 // don't go the whole distance in order to smooth out the movement
181 // don't go the whole distance in order to smooth out the movement
182− var step = distance * 0.3;
183−
184− step = d.limitMovement(step);
182+ var toAdd = d.limitMovement(distance);
185−
186− parent[d.targetProp] += step;
183+ parent[d.targetProp] = d.startValue + toAdd;
187 }
184 }
188 }
185 }
189
186