Skip to content

Commit 20ddee8

Browse files
author
Valentin Hervieu
committed
Improve positionTrackingHandle logic
1 parent e4fd9b7 commit 20ddee8

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

dist/rzslider.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,6 +1283,8 @@
12831283
* @param {number} newOffset new offset value
12841284
*/
12851285
positionTrackingHandle: function(newValue, newOffset) {
1286+
var valueChanged = false;
1287+
12861288
if (this.range) {
12871289
/* This is to check if we need to switch the min and max handles*/
12881290
if (this.tracking === 'rzSliderModel' && newValue >= this.scope.rzSliderHigh) {
@@ -1291,24 +1293,24 @@
12911293
this.tracking = 'rzSliderHigh';
12921294
this.minH.removeClass('rz-active');
12931295
this.maxH.addClass('rz-active');
1294-
/* We need to apply here because we are not sure that we will enter the next block */
1295-
this.scope.$apply();
1296-
this.callOnChange();
1296+
valueChanged = true;
12971297
} else if (this.tracking === 'rzSliderHigh' && newValue <= this.scope.rzSliderModel) {
12981298
this.scope[this.tracking] = this.scope.rzSliderModel;
12991299
this.updateHandles(this.tracking, this.minH.rzsp);
13001300
this.tracking = 'rzSliderModel';
13011301
this.maxH.removeClass('rz-active');
13021302
this.minH.addClass('rz-active');
1303-
/* We need to apply here because we are not sure that we will enter the next block */
1304-
this.scope.$apply();
1305-
this.callOnChange();
1303+
valueChanged = true;
13061304
}
13071305
}
13081306

13091307
if (this.scope[this.tracking] !== newValue) {
13101308
this.scope[this.tracking] = newValue;
13111309
this.updateHandles(this.tracking, newOffset);
1310+
valueChanged = true;
1311+
}
1312+
1313+
if(valueChanged) {
13121314
this.scope.$apply();
13131315
this.callOnChange();
13141316
}

0 commit comments

Comments
 (0)