Permalink
Browse files

Add slider step support from jQuery UI

  • Loading branch information...
jrowny authored and johnbender committed Aug 11, 2011
1 parent 47cf8d6 commit 7d204230f02314502f6cebc9a73b9d742f853f9d
Showing with 11 additions and 0 deletions.
  1. +11 −0 js/jquery.mobile.forms.slider.js
@@ -287,6 +287,17 @@ $.widget( "mobile.slider", $.mobile.widget, {
var newval = Math.round( ( percent / 100 ) * ( max - min ) ) + min;
//from jQuery UI slider, the following source will round to the neraest step
var valModStep = (newval - min) % step;
var alignValue = newval - valModStep;
if ( Math.abs(valModStep) * 2 >= step ) {
alignValue += ( valModStep > 0 ) ? step : ( -step );
}
// Since JavaScript has problems with large floats, round
// the final value to 5 digits after the decimal point (see jQuery UI: #4124)
newval = parseFloat( alignValue.toFixed(5) );
if ( newval < min ) {
newval = min;
}

0 comments on commit 7d20423

Please sign in to comment.