Skip to content

Commit 34912bc

Browse files
committed
Slider: fixed step alignment to handle negative fractional values. Fixed #5583 - Slider displays negative fractional values incorrectly. Thanks for the patch watanabe.
1 parent b7c0823 commit 34912bc

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ui/jquery.ui.slider.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -591,12 +591,12 @@ $.widget( "ui.slider", $.ui.mouse, {
591591
if ( val > this._valueMax() ) {
592592
return this._valueMax();
593593
}
594-
var step = this.options.step,
594+
var step = ( this.options.step > 0 ) ? this.options.step : 1,
595595
valModStep = val % step,
596596
alignValue = val - valModStep;
597597

598-
if ( valModStep >= ( step / 2 ) ) {
599-
alignValue += step;
598+
if ( Math.abs(valModStep) * 2 >= step ) {
599+
alignValue += ( valModStep > 0 ) ? step : ( -step );
600600
}
601601

602602
// Since JavaScript has problems with large floats, round

0 commit comments

Comments
 (0)