Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

IE8: Slider setRange([0,0]) results in division through zero #1068

hummal opened this Issue Nov 12, 2011 · 5 comments


None yet
2 participants

hummal commented Nov 12, 2011

I have to set the range to 0,0 because there is no content. This works in every browser but IE8 (below not tested).

The result is that the function toPosition(step) which is called from set(step), returns a NaN if the Range is 0,0.


return (this.full * Math.abs(this.min - step)) / (this.steps * this.stepSize) - this.options.offset;


var returnValue = 0;

if( (this.steps * this.stepSize) - this.options.offset !== 0 ) {
    returnValue = (this.full * Math.abs(this.min - step)) / (this.steps * this.stepSize) - this.options.offset;
return returnValue;

hummal commented Mar 6, 2012

issue still present in current mootools more version. No one interested?


SergioCrisostomo commented May 3, 2014

@hummal you gave very nice input to some of Slider.js's bugs. Thanks!
I am preparing a PR to fix those issues and have just this issue left which I don't understand.

In which scenario would one use range[0, 0]. ? could you make a jsFiddle with the scenario you mean? I can test it myself on IE8, I just cannot see when that would be needed.

Thank you again!

hummal commented May 5, 2014

I have the scenario, where I have an empty container which is filled dynamically after clicking on a special button. After that click it is set to the content length. I could easiely test if the content length is zero and dont set the range then, but I dont what to create special conditions. And it is working in every browser but IE8. :(


SergioCrisostomo commented May 5, 2014

@hummal thanks for feedback!
So that would create a 0 / 0 scenario and return a NaN. I see. We could solve it by adding a || 0.

I will add this to the PR:

return (this.full * Math.abs(this.min - step)) / (this.steps * this.stepSize) - this.options.offset || 0;

hummal commented May 6, 2014

Sounds great and is even shorter than my fix 2 years ago. Thank you for your effort

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment