@@ -26,32 +26,32 @@ Item {
2626 signal velocityThresholdTriggered
2727
2828 function reset() {
29+ velocityTimer.stop();
2930 stopLateralChanges = false;
3031 calc.reset();
3132 }
3233
33− function calculate() {
34+ function update() {
35+ calc.trackedPosition = trackedValue;
3436 stopLateralChanges = Math.abs(calc.calculate()) > velocityThreshold;
3537 }
3638
3739 onTrackedValueChanged: {
38− calc.trackedPosition = trackedValue;
39− velocityTimer.start();
40+ update(); // initial calculation
41+ if (root.stopLateralChanges) { // only start timer if we're above the threshold.
42+ velocityTimer.start();
43+ }
4044 }
4145
4246 AxisVelocityCalculator {
4347 id: calc
44− onTrackedPositionChanged: calculate();
4548 }
4649
4750 Timer {
4851 id: velocityTimer
4952 interval: 50
5053 onTriggered: {
51− var recalculate = calc.trackedPosition == trackedValue;
52− calc.trackedPosition = trackedValue;
53− if (recalculate) calculate();
54−
54+ update();
5555 if (root.stopLateralChanges) {
5656 velocityTimer.start();
5757 } else {