diff options
author | Scott González <scott.gonzalez@gmail.com> | 2011-08-07 19:21:23 -0400 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2011-08-07 19:21:23 -0400 |
commit | 8c5a6f7241efeb285efa6b7860e3817f04dde788 (patch) | |
tree | 76bce2baa4a5cee04adf7f2f882dc8561dc06f05 /ui/jquery.ui.spinner.js | |
parent | 2a8a77a9b287e247b2b191f9e282e82e370ee525 (diff) | |
download | jquery-ui-8c5a6f7241efeb285efa6b7860e3817f04dde788.tar.gz jquery-ui-8c5a6f7241efeb285efa6b7860e3817f04dde788.zip |
Spinner: Use a polynomial instead of hard-coded blocks for incremental stepping.
Diffstat (limited to 'ui/jquery.ui.spinner.js')
-rw-r--r-- | ui/jquery.ui.spinner.js | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/ui/jquery.ui.spinner.js b/ui/jquery.ui.spinner.js index b36bdd9fd..fecaa9b05 100644 --- a/ui/jquery.ui.spinner.js +++ b/ui/jquery.ui.spinner.js @@ -239,16 +239,7 @@ $.widget( "ui.spinner", { this.counter = 1; } - // TODO refactor, maybe figure out some non-linear math - // 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); + var newVal = this.value() + step * this._increment( this.counter ); // clamp the new value 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 ) { var options = this.options; |