Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Commit d5c4c48

Browse files
committed
add step and fixed support to slider
1 parent 2931fff commit d5c4c48

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

js/jquery.mobile.forms.slider.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ $.widget( "mobile.slider", $.mobile.widget, {
126126
var control = this.element, percent,
127127
cType = control[0].nodeName.toLowerCase(),
128128
min = (cType === "input") ? parseFloat(control.attr("min")) : 0,
129-
max = (cType === "input") ? parseFloat(control.attr("max")) : control.find("option").length - 1;
129+
max = (cType === "input") ? parseFloat(control.attr("max")) : control.find("option").length - 1,
130+
step = (cType === "input") ? parseFloat(control.attr("step")) : 1.0;
131+
fixed = (cType === "input") ? parseInt(control.attr("fixed")) : 0;
130132

131133
if ( typeof val === "object" ) {
132134
var data = val.originalEvent.touches ? val.originalEvent.touches[ 0 ] : val,
@@ -149,7 +151,7 @@ $.widget( "mobile.slider", $.mobile.widget, {
149151
if ( percent < 0 ) { percent = 0; }
150152
if ( percent > 100 ) { percent = 100; }
151153

152-
var newval = Math.round( (percent / 100) * (max - min) ) + min;
154+
var newval = ((Math.round( (percent / 100) * (max - min) ) + min) * step).toFixed(fixed);
153155
if ( newval < min ) { newval = min; }
154156
if ( newval > max ) { newval = max; }
155157

0 commit comments

Comments
 (0)