Skip to content

Commit fb033f0

Browse files
committed
Fixed number precision when draggableRange=true
When there was set options.precision>0 (non-zero fraction part) and moved a range there was a issue with number rounding on both ends of selected range. Sometimes numbers had small value at far fraction. It can be reproduced with live demo by setting, for example: minValue: 3.6, maxValue: 5.8 floor: 0, ceil: 10 step: 0.1, precision: 1, draggableRange: true It's possible to produce value, e.g: 6.2999999999... but used precision expects to see rounded value: 6.3.
1 parent 85afa53 commit fb033f0

File tree

5 files changed

+11
-5
lines changed

5 files changed

+11
-5
lines changed

dist/rzslider.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*! angularjs-slider - v2.9.0 -
22
(c) Rafal Zajac <[email protected]>, Valentin Hervieu <[email protected]>, Jussi Saarivirta <[email protected]>, Angelin Sirbu <[email protected]> -
33
https://github.com/angular-slider/angularjs-slider -
4-
2016-02-18 */
4+
2016-02-24 */
55
rzslider {
66
position: relative;
77
display: inline-block;

dist/rzslider.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*! angularjs-slider - v2.9.0 -
22
(c) Rafal Zajac <[email protected]>, Valentin Hervieu <[email protected]>, Jussi Saarivirta <[email protected]>, Angelin Sirbu <[email protected]> -
33
https://github.com/angular-slider/angularjs-slider -
4-
2016-02-18 */
4+
2016-02-24 */
55
/*jslint unparam: true */
66
/*global angular: false, console: false, define, module */
77
(function(root, factory) {
@@ -1549,15 +1549,18 @@
15491549
return;
15501550
newMinValue = this.minValue;
15511551
newMaxValue = this.minValue + this.dragging.difference;
1552+
newMaxValue = this.roundStep(newMaxValue);
15521553
} else if (newOffset >= this.maxPos - this.dragging.highLimit) {
15531554
if (this.maxH.rzsp === this.maxPos)
15541555
return;
15551556
newMaxValue = this.maxValue;
15561557
newMinValue = this.maxValue - this.dragging.difference;
1558+
newMinValue = this.roundStep(newMinValue);
15571559
} else {
15581560
newMinValue = this.offsetToValue(newOffset - this.dragging.lowLimit);
15591561
newMinValue = this.roundStep(newMinValue);
15601562
newMaxValue = newMinValue + this.dragging.difference;
1563+
newMaxValue = this.roundStep(newMaxValue);
15611564
}
15621565

15631566
this.positionTrackingBar(newMinValue, newMaxValue);

dist/rzslider.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rzslider.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/rzslider.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1553,15 +1553,18 @@
15531553
return;
15541554
newMinValue = this.minValue;
15551555
newMaxValue = this.minValue + this.dragging.difference;
1556+
newMaxValue = this.roundStep(newMaxValue);
15561557
} else if (newOffset >= this.maxPos - this.dragging.highLimit) {
15571558
if (this.maxH.rzsp === this.maxPos)
15581559
return;
15591560
newMaxValue = this.maxValue;
15601561
newMinValue = this.maxValue - this.dragging.difference;
1562+
newMinValue = this.roundStep(newMinValue);
15611563
} else {
15621564
newMinValue = this.offsetToValue(newOffset - this.dragging.lowLimit);
15631565
newMinValue = this.roundStep(newMinValue);
15641566
newMaxValue = newMinValue + this.dragging.difference;
1567+
newMaxValue = this.roundStep(newMaxValue);
15651568
}
15661569

15671570
this.positionTrackingBar(newMinValue, newMaxValue);

0 commit comments

Comments
 (0)