Commit 20ddee8c authored by Valentin Hervieu's avatar Valentin Hervieu

Improve positionTrackingHandle logic

parent e4fd9b7f
...@@ -1283,6 +1283,8 @@ ...@@ -1283,6 +1283,8 @@
* @param {number} newOffset new offset value * @param {number} newOffset new offset value
*/ */
positionTrackingHandle: function(newValue, newOffset) { positionTrackingHandle: function(newValue, newOffset) {
var valueChanged = false;
if (this.range) { if (this.range) {
/* This is to check if we need to switch the min and max handles*/ /* This is to check if we need to switch the min and max handles*/
if (this.tracking === 'rzSliderModel' && newValue >= this.scope.rzSliderHigh) { if (this.tracking === 'rzSliderModel' && newValue >= this.scope.rzSliderHigh) {
...@@ -1291,24 +1293,24 @@ ...@@ -1291,24 +1293,24 @@
this.tracking = 'rzSliderHigh'; this.tracking = 'rzSliderHigh';
this.minH.removeClass('rz-active'); this.minH.removeClass('rz-active');
this.maxH.addClass('rz-active'); this.maxH.addClass('rz-active');
/* We need to apply here because we are not sure that we will enter the next block */ valueChanged = true;
this.scope.$apply();
this.callOnChange();
} else if (this.tracking === 'rzSliderHigh' && newValue <= this.scope.rzSliderModel) { } else if (this.tracking === 'rzSliderHigh' && newValue <= this.scope.rzSliderModel) {
this.scope[this.tracking] = this.scope.rzSliderModel; this.scope[this.tracking] = this.scope.rzSliderModel;
this.updateHandles(this.tracking, this.minH.rzsp); this.updateHandles(this.tracking, this.minH.rzsp);
this.tracking = 'rzSliderModel'; this.tracking = 'rzSliderModel';
this.maxH.removeClass('rz-active'); this.maxH.removeClass('rz-active');
this.minH.addClass('rz-active'); this.minH.addClass('rz-active');
/* We need to apply here because we are not sure that we will enter the next block */ valueChanged = true;
this.scope.$apply();
this.callOnChange();
} }
} }
if (this.scope[this.tracking] !== newValue) { if (this.scope[this.tracking] !== newValue) {
this.scope[this.tracking] = newValue; this.scope[this.tracking] = newValue;
this.updateHandles(this.tracking, newOffset); this.updateHandles(this.tracking, newOffset);
valueChanged = true;
}
if(valueChanged) {
this.scope.$apply(); this.scope.$apply();
this.callOnChange(); this.callOnChange();
} }
......
This diff is collapsed.
...@@ -1283,6 +1283,8 @@ ...@@ -1283,6 +1283,8 @@
* @param {number} newOffset new offset value * @param {number} newOffset new offset value
*/ */
positionTrackingHandle: function(newValue, newOffset) { positionTrackingHandle: function(newValue, newOffset) {
var valueChanged = false;
if (this.range) { if (this.range) {
/* This is to check if we need to switch the min and max handles*/ /* This is to check if we need to switch the min and max handles*/
if (this.tracking === 'rzSliderModel' && newValue >= this.scope.rzSliderHigh) { if (this.tracking === 'rzSliderModel' && newValue >= this.scope.rzSliderHigh) {
...@@ -1291,24 +1293,24 @@ ...@@ -1291,24 +1293,24 @@
this.tracking = 'rzSliderHigh'; this.tracking = 'rzSliderHigh';
this.minH.removeClass('rz-active'); this.minH.removeClass('rz-active');
this.maxH.addClass('rz-active'); this.maxH.addClass('rz-active');
/* We need to apply here because we are not sure that we will enter the next block */ valueChanged = true;
this.scope.$apply();
this.callOnChange();
} else if (this.tracking === 'rzSliderHigh' && newValue <= this.scope.rzSliderModel) { } else if (this.tracking === 'rzSliderHigh' && newValue <= this.scope.rzSliderModel) {
this.scope[this.tracking] = this.scope.rzSliderModel; this.scope[this.tracking] = this.scope.rzSliderModel;
this.updateHandles(this.tracking, this.minH.rzsp); this.updateHandles(this.tracking, this.minH.rzsp);
this.tracking = 'rzSliderModel'; this.tracking = 'rzSliderModel';
this.maxH.removeClass('rz-active'); this.maxH.removeClass('rz-active');
this.minH.addClass('rz-active'); this.minH.addClass('rz-active');
/* We need to apply here because we are not sure that we will enter the next block */ valueChanged = true;
this.scope.$apply();
this.callOnChange();
} }
} }
if (this.scope[this.tracking] !== newValue) { if (this.scope[this.tracking] !== newValue) {
this.scope[this.tracking] = newValue; this.scope[this.tracking] = newValue;
this.updateHandles(this.tracking, newOffset); this.updateHandles(this.tracking, newOffset);
valueChanged = true;
}
if(valueChanged) {
this.scope.$apply(); this.scope.$apply();
this.callOnChange(); this.callOnChange();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment