Commit c783a1c60468522961e89a1e189a477f6c18c176

Authored by Kalutka Zhenya
Committed by Andrew Shvayka
1 parent 86db8217

Fix knob control on 2.5.5

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