on xenial help sign in
even better velocity calc
commit76cbe213632cd786a5fa9a73ac1f73077e7e7733 authorNick Dedekind <nick.dedekind@canonical.com> dateMon 13 Oct 2014, 18:02 (12 years ago) parentdc1cda6
1 file changed+9−12
qml/Panel/PanelVelocityCalculator.qml+9−12
qml/Panel/PanelVelocityCalculator.qml+9−12
@@ -32,17 +32,21 @@ Item {
3232 }
3333
3434 function update() {
35+ var previouslyStopped = stopLateralChanges;
36+
3537 calc.trackedPosition = trackedValue;
3638 stopLateralChanges = Math.abs(calc.calculate()) > velocityThreshold;
37− }
3839
39− onTrackedValueChanged: {
40− update(); // initial calculation
41− if (root.stopLateralChanges) { // only start timer if we're above the threshold.
40+ if (stopLateralChanges) { // only start timer if we're above the threshold.
4241 velocityTimer.start();
42+ } else if (previouslyStopped) { // if we have previously been stopped, then trigger the signal
43+ velocityTimer.stop();
44+ velocityThresholdTriggered();
4345 }
4446 }
4547
48+ onTrackedValueChanged: update();
49+
4650 AxisVelocityCalculator {
4751 id: calc
4852 }
@@ -50,13 +54,6 @@ Item {
5054 Timer {
5155 id: velocityTimer
5256 interval: 50
53− onTriggered: {
54− update();
55− if (root.stopLateralChanges) {
56− velocityTimer.start();
57− } else {
58− velocityThresholdTriggered();
59− }
60− }
57+ onTriggered: update();
6158 }
6259}