18 import Ubuntu.Components 0.1
19 import Ubuntu.Gestures 0.1
48 objectName:
"dragHandle"
53 distanceThreshold: hintDisplacement > 0 ? 0 : defaultDistanceThreshold
54 maxSilenceTime: hintDisplacement > 0 ? 60*60*1000 : defaultMaxSilenceTime
55 maxDeviation: hintDisplacement > 0 ? 999999 : defaultMaxDeviation
57 property bool stretch:
false
59 property alias autoCompleteDragThreshold: dragEvaluator.dragThreshold
62 property real maxTotalDragDistance: {
66 Direction.isHorizontal(direction) ? parent.width : parent.height;
70 property real hintDisplacement: 0
73 target: hintingAnimation
74 property:
"targetValue"
77 to: Direction.isPositive(direction) ? d.startValue + hintDisplacement
78 : d.startValue - hintDisplacement
79 property real targetValue
80 onTargetValueChanged: {
85 if (Direction.isPositive(direction)) {
86 if (parent[d.targetProp] < targetValue) {
87 parent[d.targetProp] = targetValue;
90 if (parent[d.targetProp] > targetValue) {
91 parent[d.targetProp] = targetValue;
100 property var previousStatus: DirectionalDragArea.WaitingForTouch
101 property real startValue
102 property real minValue: Direction.isPositive(direction) ? startValue
103 : startValue - maxTotalDragDistance
104 property real maxValue: Direction.isPositive(direction) ? startValue + maxTotalDragDistance
107 property var dragParent: dragArea.parent
110 property string targetProp: {
112 Direction.isHorizontal(direction) ?
"width" :
"height";
114 Direction.isHorizontal(direction) ?
"x" :
"y";
118 function limitMovement(inputStep) {
119 var targetValue = MathUtils.clamp(dragParent[targetProp] + inputStep, minValue, maxValue);
120 var step = targetValue - dragParent[targetProp];
122 if (hintDisplacement == 0) {
127 if (Direction.isPositive(direction)) {
128 if (dragParent[targetProp] + step < hintingAnimation.targetValue) {
129 step = hintingAnimation.targetValue - dragParent[targetProp];
132 if (dragParent[targetProp] + step > hintingAnimation.targetValue) {
133 step = hintingAnimation.targetValue - dragParent[targetProp];
140 function onFinishedRecognizedGesture() {
141 if (dragEvaluator.shouldAutoComplete()) {
148 function completeDrag() {
149 if (dragParent.shown) {
156 function rollbackDrag() {
157 if (dragParent.shown) {
165 property alias edgeDragEvaluator: dragEvaluator
168 objectName:
"edgeDragEvaluator"
171 trackedPosition: Direction.isPositive(dragArea.direction) ? sceneDistance : -sceneDistance
172 maxDragDistance: maxTotalDragDistance
173 direction: dragArea.direction
177 if (status === DirectionalDragArea.Recognized) {
179 var step = distance * 0.3;
181 step = d.limitMovement(step);
183 parent[d.targetProp] += step;
188 if (status === DirectionalDragArea.WaitingForTouch) {
189 hintingAnimation.stop();
190 if (d.previousStatus === DirectionalDragArea.Recognized) {
191 d.onFinishedRecognizedGesture();
197 if (d.previousStatus === DirectionalDragArea.WaitingForTouch) {
198 dragEvaluator.reset();
199 d.startValue = parent[d.targetProp];
201 if (hintDisplacement > 0) {
202 hintingAnimation.targetValue = d.startValue;
203 hintingAnimation.start();
208 d.previousStatus = status;