From: Richard D. Worth Date: Tue, 11 May 2010 12:17:18 +0000 (-0400) Subject: Slider: fixed step alignment to handle negative fractional values. Fixed #5583 -... X-Git-Tag: 1.8.2~12 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=34912bc933d2787b0e3143b4dbd84e70bcc67928;p=jquery-ui.git Slider: fixed step alignment to handle negative fractional values. Fixed #5583 - Slider displays negative fractional values incorrectly. Thanks for the patch watanabe. --- diff --git a/ui/jquery.ui.slider.js b/ui/jquery.ui.slider.js index 895b536c2..210ca769a 100644 --- a/ui/jquery.ui.slider.js +++ b/ui/jquery.ui.slider.js @@ -591,12 +591,12 @@ $.widget( "ui.slider", $.ui.mouse, { if ( val > this._valueMax() ) { return this._valueMax(); } - var step = this.options.step, + var step = ( this.options.step > 0 ) ? this.options.step : 1, valModStep = val % step, alignValue = val - valModStep; - if ( valModStep >= ( step / 2 ) ) { - alignValue += step; + if ( Math.abs(valModStep) * 2 >= step ) { + alignValue += ( valModStep > 0 ) ? step : ( -step ); } // Since JavaScript has problems with large floats, round