aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAblay Keldibek <atomio.ak@gmail.com>2015-03-04 18:23:17 +0600
committerScott González <scott.gonzalez@gmail.com>2015-03-10 12:25:12 -0400
commit0f99e9c9693b05199d9f8c1137606c7033e19f38 (patch)
treececc1549c4b324f4aa9755e067f1e0e5a0889e24
parent31e7099709a3bccaae8f83d397951096835269a2 (diff)
downloadjquery-ui-0f99e9c9693b05199d9f8c1137606c7033e19f38.tar.gz
jquery-ui-0f99e9c9693b05199d9f8c1137606c7033e19f38.zip
Slider: Modified to allow value to reach max value with float step
Fixes #11286 Closes gh-1465 (cherry picked from commit 60c00cd4ecdab41f44e125efe2679223e9cd5535)
-rw-r--r--tests/unit/slider/slider_methods.js12
-rw-r--r--ui/slider.js2
2 files changed, 12 insertions, 2 deletions
diff --git a/tests/unit/slider/slider_methods.js b/tests/unit/slider/slider_methods.js
index c5c7e1254..ce26620e2 100644
--- a/tests/unit/slider/slider_methods.js
+++ b/tests/unit/slider/slider_methods.js
@@ -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() {
diff --git a/ui/slider.js b/ui/slider.js
index edc8b4027..65204ca91 100644
--- a/ui/slider.js
+++ b/ui/slider.js
@@ -550,7 +550,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() ) );
},