on xenial help sign in
performance tweaks.
dc1cda6Nick Dedekind
qml/Panel/PanelVelocityCalculator.qml+8−8
@@ -26,32 +26,32 @@ Item {
26 signal velocityThresholdTriggered
26 signal velocityThresholdTriggered
27
27
28 function reset() {
28 function reset() {
29+ velocityTimer.stop();
29 stopLateralChanges = false;
30 stopLateralChanges = false;
30 calc.reset();
31 calc.reset();
31 }
32 }
32
33
33− function calculate() {
34+ function update() {
35+ calc.trackedPosition = trackedValue;
34 stopLateralChanges = Math.abs(calc.calculate()) > velocityThreshold;
36 stopLateralChanges = Math.abs(calc.calculate()) > velocityThreshold;
35 }
37 }
36
38
37 onTrackedValueChanged: {
39 onTrackedValueChanged: {
38− calc.trackedPosition = trackedValue;
40+ update(); // initial calculation
41+ if (root.stopLateralChanges) { // only start timer if we're above the threshold.
39− velocityTimer.start();
42+ velocityTimer.start();
43+ }
40 }
44 }
41
45
42 AxisVelocityCalculator {
46 AxisVelocityCalculator {
43 id: calc
47 id: calc
44− onTrackedPositionChanged: calculate();
45 }
48 }
46
49
47 Timer {
50 Timer {
48 id: velocityTimer
51 id: velocityTimer
49 interval: 50
52 interval: 50
50 onTriggered: {
53 onTriggered: {
51− var recalculate = calc.trackedPosition == trackedValue;
54+ update();
52− calc.trackedPosition = trackedValue;
53− if (recalculate) calculate();
54−
55 if (root.stopLateralChanges) {
55 if (root.stopLateralChanges) {
56 velocityTimer.start();
56 velocityTimer.start();
57 } else {
57 } else {