Skip to content
Permalink
Browse files

Spinner: Improved mousewheel event handling

  • Loading branch information...
jzaefferer committed Oct 27, 2010
1 parent d91cd61 commit 78872dca42bad0e58a8e0bd34c415c036d97ebe4
Showing with 7 additions and 4 deletions.
  1. +7 −4 ui/jquery.ui.spinner.js
@@ -183,23 +183,26 @@ $.widget('ui.spinner', {
},

_mousewheel: function() {
// need the delta normalization that mousewheel plugin provides
if (!$.fn.mousewheel) {
return;
}
var self = this;
this.element.bind("mousewheel.spinner", function(event, delta) {
if (self.options.disabled) {
return;
}
if (!self._start(event)) {
if (!self.spinning && !self._start(event)) {
return false;
}
self._spin((delta > 0 ? 1 : -1) * self.options.step, event);
clearTimeout(self.timeout);
// TODO can we implement that without a timeout?
self.timeout = setTimeout(function() {
if (self.spinning) {
self._stop(event);
self._change(event);
}
}, 13);
}, 100);
event.preventDefault();
});
},
@@ -214,7 +217,7 @@ $.widget('ui.spinner', {
},

_start: function(event) {
if (!this.spinning && this._trigger('start', event, { value: this.options.value}) !== false) {
if (!this.spinning && this._trigger('start', event) !== false) {
if (!this.counter) {
this.counter = 1;
}

0 comments on commit 78872dc

Please sign in to comment.
You can’t perform that action at this time.