Skip to content

Commit 60c00cd

Browse files
atomiomiscottgonzalez
authored andcommitted
Slider: Modified to allow value to reach max value with float step
Fixes #11286 Closes jquerygh-1465
1 parent af4c35d commit 60c00cd

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

tests/unit/slider/slider_methods.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ test( "disable", function() {
6262
});
6363

6464
test( "value", function() {
65-
expect( 17 );
65+
expect( 18 );
6666
$( [ false, "min", "max" ] ).each(function() {
6767
var element = $( "<div></div>" ).slider({
6868
range: this,
@@ -88,6 +88,16 @@ test( "value", function() {
8888
equal( element.slider( "value" ), 1, "value method get respects max" );
8989
equal( element.slider( "value", 2 ), element, "value method is chainable" );
9090
equal( element.slider( "option", "value" ), 1, "value method set respects max" );
91+
92+
// set max value with step 0.01
93+
element.slider( "option", {
94+
min: 2,
95+
value: 2,
96+
max: 2.4,
97+
step: 0.01
98+
});
99+
element.slider( "option", "value", 2.4 );
100+
equal( element.slider( "value" ), 2.4, "value is set to max with 0.01 step" );
91101
});
92102

93103
//test( "values", function() {

ui/slider.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ return $.widget( "ui.slider", $.ui.mouse, {
558558
var max = this.options.max,
559559
min = this._valueMin(),
560560
step = this.options.step,
561-
aboveMin = Math.floor( ( max - min ) / step ) * step;
561+
aboveMin = Math.floor( ( +( max - min ).toFixed( this._precision() ) ) / step ) * step;
562562
max = aboveMin + min;
563563
this.max = parseFloat( max.toFixed( this._precision() ) );
564564
},

0 commit comments

Comments
 (0)