mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Spinner: Use a polynomial instead of hard-coded blocks for incremental stepping.
This commit is contained in:
parent
2a8a77a9b2
commit
8c5a6f7241
17
ui/jquery.ui.spinner.js
vendored
17
ui/jquery.ui.spinner.js
vendored
@ -239,16 +239,7 @@ $.widget( "ui.spinner", {
|
|||||||
this.counter = 1;
|
this.counter = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO refactor, maybe figure out some non-linear math
|
var newVal = this.value() + step * this._increment( this.counter );
|
||||||
// x*x*x/50000 - x*x/500 + 17*x/200 + 1
|
|
||||||
var newVal = this.value() + step * (this.options.incremental &&
|
|
||||||
this.counter > 20
|
|
||||||
? this.counter > 100
|
|
||||||
? this.counter > 200
|
|
||||||
? 100
|
|
||||||
: 10
|
|
||||||
: 2
|
|
||||||
: 1);
|
|
||||||
|
|
||||||
// clamp the new value
|
// clamp the new value
|
||||||
newVal = this._trimValue( newVal );
|
newVal = this._trimValue( newVal );
|
||||||
@ -259,6 +250,12 @@ $.widget( "ui.spinner", {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_increment: function( i ) {
|
||||||
|
return this.options.incremental ?
|
||||||
|
Math.floor( i*i*i/50000 - i*i/500 + 17*i/200 + 1 ) :
|
||||||
|
1;
|
||||||
|
},
|
||||||
|
|
||||||
_trimValue: function( value ) {
|
_trimValue: function( value ) {
|
||||||
var options = this.options;
|
var options = this.options;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user