Skip to content

Conversation

@dekajp
Copy link
Contributor

@dekajp dekajp commented Dec 16, 2014

Fixes #10721

new _calculateNewMax method uses while loop, the cost should be very minimum
since this method is called one time in life of control, in create method or
when setOption(max) is called.

below method uses math functions to avoid loop, but this was failing
unit tests of slider_options.

TODO : to avoid while loop in Max Calculation

 _calculateNewMax: function() { var precision = this._precision(); var multiplier = Math.pow( 10 , precision ); var max = this.options.max * multiplier ; var min = this._valueMin() * multiplier ; var step = this.options.step * multiplier ; var remainder = ( max - min ) % step; this.max = ( ( max - remainder ) / multiplier ).toFixed(precision); } 
@jzaefferer
Copy link
Member

@dekajp were you going to update this to address your own TODO?

@dekajp
Copy link
Contributor Author

dekajp commented Dec 23, 2014

@jzaefferer I am not planning as of now.

@dekajp
Copy link
Contributor Author

dekajp commented Dec 30, 2014

@jzaefferer i think i now know the reason why the TODO method was not working , this should fix it.
this.max = parseFloat( ( ( max - remainder ) / multiplier ).toFixed(precision) );

i will send a updated PR . i did not know toFixed was returning string. my bad

ui/slider.js Outdated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove all of the extraneous parens.

scottgonzalez pushed a commit that referenced this pull request Feb 9, 2015
Fixes #10721 Closes gh-1398 (cherry picked from commit ae1d6d5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants