Skip to content
Permalink
Browse files

Add support for mousewheel

  • Loading branch information
Keith Wood
Keith Wood committed Aug 10, 2008
1 parent a397752 commit c400d7d68ddd1a8e05b3e6298a760fcfac55a79b
Showing with 11 additions and 0 deletions.
  1. +11 −0 ui/ui.spinner.js
@@ -57,6 +57,9 @@ $.widget("ui.spinner", {
self.propagate("change", e);
})
;
if ($.fn.mousewheel) {
this.element.mousewheel(function(e, delta) { self.mousewheel(e, delta); });
}

},
plugins: {},
@@ -97,6 +100,11 @@ $.widget("ui.spinner", {
if(e.keyCode == 36) this.element[0].value = this.options.min || this.options.start; //Home key goes to min, if defined, else to start
if(e.keyCode == 35 && this.options.max != undefined) this.element[0].value = this.options.max; //End key goes to maximum
},
mousewheel: function(e, delta) {
delta = ($.browser.opera ? -delta / Math.abs(delta) : delta);
delta > 0 ? this.up(e) : this.down(e);
e.preventDefault();
},
ui: function(e) {
return {
instance: this,
@@ -114,6 +122,9 @@ $.widget("ui.spinner", {
.removeClass("ui-spinner ui-spinner-disabled")
.removeData("spinner")
.unbind(".spinner");
if ($.fn.mousewheel) {
this.element.unmousewheel();
}
}
});

0 comments on commit c400d7d

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