slider: limit the returned floats to 5 digits after the decimal point, corrects JS float errors (fixes #4124 - Value should always be constrained to valid step values)

This commit is contained in:
Paul Bakaus 2009-02-17 13:01:19 +00:00
parent 9c4b8a9141
commit 2ffcf02de3

View File

@ -287,7 +287,9 @@ $.widget("ui.slider", $.extend({}, $.ui.mouse, {
if (valueMouseModStep > (this.options.step / 2))
normValue += this.options.step;
return normValue;
// Since JavaScript has problems with large floats, round
// the final value to 5 digits after the decimal point (see #4124)
return parseFloat(normValue.toFixed(5));
},