mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-05-23 05:35:48 +00:00
Add slider step support from jQuery UI
This commit is contained in:
parent
47cf8d61b1
commit
7d204230f0
1 changed files with 11 additions and 0 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue