var range = new Powerange(el, {
min: 1,
max: 3,
start: 3
})
The slider will init in the 2nd step instead of the last one.
This is caused because of the following steps iteration:
// main.js:200
for (i = 0; i <= dimension; i += interval) {
// ...
The issue here is that when working with decimal numbers, in javascript 0.1 + 0.2 != 0.3 ever!
So, the <= evaluation never reaches the = part and therefore in those scenarios the this.steps array always ends up with less steps than it should have.
The solution I found is replacing the <= for a strict < and the top most dimension + 1 leading to this iteration:
// main.js:200
for (i = 0; i < dimension + 1; i += interval) {
// ...
Working for both integer and decimal iterations!
And of course filling the this.steps array with the correct amount of steps.
When using a config like the following:
The slider will init in the 2nd step instead of the last one.
This is caused because of the following steps iteration:
The issue here is that when working with decimal numbers, in javascript
0.1 + 0.2 != 0.3
ever!So, the
<=
evaluation never reaches the=
part and therefore in those scenarios thethis.steps
array always ends up with less steps than it should have.The solution I found is replacing the
<=
for a strict<
and the top mostdimension + 1
leading to this iteration:Working for both integer and decimal iterations!
And of course filling the
this.steps
array with the correct amount of steps.Let me know what you think of this.