on xenial help sign in
Fix DragHandle
commit91c46b9887a486ac1e6cb8badce4188f5e47abb9 authorAlbert Astals Cid <albert.astals@canonical.com> dateWed 9 Dec 2015, 11:06 (11 years ago) parentae56389
1 file changed+11−14
qml/Components/DragHandle.qml+11−14
qml/Components/DragHandle.qml+11−14
@@ -118,26 +118,26 @@ SwipeArea {
118118 }
119119 }
120120
121− function limitMovement(inputStep) {
122− var targetValue = MathUtils.clamp(dragParent[targetProp] + inputStep, minValue, maxValue);
123− var step = targetValue - dragParent[targetProp];
121+ function limitMovement(distance) {
122+ var targetValue = MathUtils.clamp(d.startValue + distance, minValue, maxValue);
123+ var diff = targetValue - d.startValue;
124124
125125 if (hintDisplacement == 0) {
126− return step;
126+ return diff;
127127 }
128128
129129 // we should not go behind hintingAnimation's current value
130130 if (Direction.isPositive(direction)) {
131− if (dragParent[targetProp] + step < hintingAnimation.targetValue) {
132− step = hintingAnimation.targetValue - dragParent[targetProp];
131+ if (d.startValue + diff < hintingAnimation.targetValue) {
132+ diff = hintingAnimation.targetValue - d.startValue;
133133 }
134134 } else {
135− if (dragParent[targetProp] + step > hintingAnimation.targetValue) {
136− step = hintingAnimation.targetValue - dragParent[targetProp];
135+ if (d.startValue + diff > hintingAnimation.targetValue) {
136+ diff = hintingAnimation.targetValue - d.startValue;
137137 }
138138 }
139139
140− return step;
140+ return diff;
141141 }
142142
143143 function onFinishedRecognizedGesture() {
@@ -179,11 +179,8 @@ SwipeArea {
179179 onDistanceChanged: {
180180 if (dragging) {
181181 // 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);
185−
186− parent[d.targetProp] += step;
182+ var toAdd = d.limitMovement(distance);
183+ parent[d.targetProp] = d.startValue + toAdd;
187184 }
188185 }
189186