Commit c783a1c60468522961e89a1e189a477f6c18c176
Committed by
Andrew Shvayka
1 parent
86db8217
Fix knob control on 2.5.5
Showing
1 changed file
with
12 additions
and
6 deletions
... | ... | @@ -50,6 +50,7 @@ function KnobController($element, $scope, $document) { |
50 | 50 | |
51 | 51 | vm.value = 0; |
52 | 52 | vm.error = ''; |
53 | + vm.newValue = 0; | |
53 | 54 | |
54 | 55 | var knob = angular.element('.knob', $element), |
55 | 56 | knobContainer = angular.element('#knob-container', $element), |
... | ... | @@ -145,9 +146,11 @@ function KnobController($element, $scope, $document) { |
145 | 146 | turn(degreeToRatio(currentDeg)); |
146 | 147 | rotation = currentDeg; |
147 | 148 | startDeg = -1; |
149 | + rpcUpdateValue(vm.newValue); | |
148 | 150 | }); |
149 | 151 | |
150 | 152 | knob.on('mousedown touchstart', (e) => { |
153 | + moving = false; | |
151 | 154 | e.preventDefault(); |
152 | 155 | var offset = knob.offset(); |
153 | 156 | var center = { |
... | ... | @@ -158,7 +161,7 @@ function KnobController($element, $scope, $document) { |
158 | 161 | var a, b, deg, tmp, |
159 | 162 | rad2deg = 180/Math.PI; |
160 | 163 | |
161 | - knob.on('mousemove.rem touchmove.rem', (e) => { | |
164 | + $document.on('mousemove.rem touchmove.rem', (e) => { | |
162 | 165 | moving = true; |
163 | 166 | e = (e.originalEvent.touches) ? e.originalEvent.touches[0] : e; |
164 | 167 | |
... | ... | @@ -209,6 +212,9 @@ function KnobController($element, $scope, $document) { |
209 | 212 | }); |
210 | 213 | |
211 | 214 | $document.on('mouseup.rem touchend.rem',() => { |
215 | + if(moving) { | |
216 | + rpcUpdateValue(vm.newValue); | |
217 | + } | |
212 | 218 | knob.off('.rem'); |
213 | 219 | $document.off('.rem'); |
214 | 220 | rotation = currentDeg; |
... | ... | @@ -269,12 +275,12 @@ function KnobController($element, $scope, $document) { |
269 | 275 | } |
270 | 276 | |
271 | 277 | function turn(ratio) { |
272 | - var value = (vm.minValue + (vm.maxValue - vm.minValue)*ratio).toFixed(vm.ctx.decimals); | |
273 | - if (canvasBar.value != value) { | |
274 | - canvasBar.value = value; | |
278 | + vm.newValue = (vm.minValue + (vm.maxValue - vm.minValue)*ratio).toFixed(vm.ctx.decimals); | |
279 | + if (canvasBar.value != vm.newValue) { | |
280 | + canvasBar.value = vm.newValue; | |
275 | 281 | } |
276 | 282 | updateColor(canvasBar.getValueColor()); |
277 | - onValue(value); | |
283 | + onValue(vm.newValue); | |
278 | 284 | } |
279 | 285 | |
280 | 286 | function setValue(value) { |
... | ... | @@ -303,7 +309,7 @@ function KnobController($element, $scope, $document) { |
303 | 309 | $scope.$applyAsync(() => { |
304 | 310 | vm.value = formatValue(value); |
305 | 311 | checkValueSize(); |
306 | - rpcUpdateValue(value); | |
312 | + // rpcUpdateValue(vm.newValue); | |
307 | 313 | }); |
308 | 314 | } |
309 | 315 | ... | ... |