Slider: fixed step alignment to handle negative fractional values. Fixed #5583 - Slider displays negative fractional values incorrectly. Thanks for the patch watanabe.

This commit is contained in:
Richard D. Worth 2010-05-11 08:17:18 -04:00
parent b7c0823da6
commit 34912bc933

View File

@ -591,12 +591,12 @@ $.widget( "ui.slider", $.ui.mouse, {
if ( val > this._valueMax() ) { if ( val > this._valueMax() ) {
return this._valueMax(); return this._valueMax();
} }
var step = this.options.step, var step = ( this.options.step > 0 ) ? this.options.step : 1,
valModStep = val % step, valModStep = val % step,
alignValue = val - valModStep; alignValue = val - valModStep;
if ( valModStep >= ( step / 2 ) ) { if ( Math.abs(valModStep) * 2 >= step ) {
alignValue += step; alignValue += ( valModStep > 0 ) ? step : ( -step );
} }
// Since JavaScript has problems with large floats, round // Since JavaScript has problems with large floats, round