18 import Ubuntu.Components 0.1
19 import Ubuntu.Gestures 0.1
27 AxisVelocityCalculator {
30 property real maxDragDistance
36 property real dragThreshold: maxDragDistance / 2
38 property real minDragDistance: maxDragDistance * 0.1
46 property real speedThreshold: units.gu(70)
48 property int direction
50 property real velocity
51 property real minVelocity
54 function shouldAutoComplete() {
55 var deltaPos = trackedPosition - __startPosition;
56 if (Math.abs(deltaPos) < minDragDistance) {
62 minVelocity = __calculateMinimumVelocityForAutoCompletion(deltaPos);
63 velocity = calculate();
65 if (Direction.isPositive(direction) && (velocity >= minVelocity)
66 || !Direction.isPositive(direction) && (velocity <= minVelocity)) {
73 property real __startPosition
76 property real __speedThresholdMs: speedThreshold / 1000.0
79 property real __v0: Direction.isPositive(direction) ? __speedThresholdMs : - __speedThresholdMs
81 function __calculateMinimumVelocityForAutoCompletion(distance) {
82 return __v0 - ((__speedThresholdMs / dragThreshold) * distance);
86 __startPosition = trackedPosition;