]> source.dussan.org Git - jquery-ui.git/commitdiff
Slider: Modified to allow value to reach max value with float step
authorAblay Keldibek <atomio.ak@gmail.com>
Wed, 4 Mar 2015 12:23:17 +0000 (18:23 +0600)
committerScott González <scott.gonzalez@gmail.com>
Thu, 5 Mar 2015 18:16:54 +0000 (13:16 -0500)
Fixes #11286
Closes gh-1465

tests/unit/slider/slider_methods.js
ui/slider.js

index c5c7e1254aaf85abef3d0106ed72492ccd382df7..ce26620e22173b53713415d36f23b3bfa661f200 100644 (file)
@@ -62,7 +62,7 @@ test( "disable", function() {
 });
 
 test( "value", function() {
-       expect( 17 );
+       expect( 18 );
        $( [ false, "min", "max" ] ).each(function() {
                var element = $( "<div></div>" ).slider({
                        range: this,
@@ -88,6 +88,16 @@ test( "value", function() {
        equal( element.slider( "value" ), 1, "value method get respects max" );
        equal( element.slider( "value", 2 ), element, "value method is chainable" );
        equal( element.slider( "option", "value" ), 1, "value method set respects max" );
+
+       // set max value with step 0.01
+       element.slider( "option", {
+               min: 2,
+               value: 2,
+               max: 2.4,
+               step: 0.01
+       });
+       element.slider( "option", "value", 2.4 );
+       equal( element.slider( "value" ), 2.4, "value is set to max with 0.01 step" );
 });
 
 //test( "values", function() {
index 4af7dc34fde7eb895e614dc7755a7e472da4d64b..fceb367f31c8ec714b4c25b6c333ab80872b1874 100644 (file)
@@ -558,7 +558,7 @@ return $.widget( "ui.slider", $.ui.mouse, {
                var max = this.options.max,
                        min = this._valueMin(),
                        step = this.options.step,
-                       aboveMin = Math.floor( ( max - min ) / step ) * step;
+                       aboveMin = Math.floor( ( +( max - min ).toFixed( this._precision() ) ) / step ) * step;
                max = aboveMin + min;
                this.max = parseFloat( max.toFixed( this._precision() ) );
        },