]> source.dussan.org Git - jquery-ui.git/commitdiff
Add support for mousewheel
authorKeith Wood <kbwood.au@gmail.com>
Sun, 10 Aug 2008 07:28:44 +0000 (07:28 +0000)
committerKeith Wood <kbwood.au@gmail.com>
Sun, 10 Aug 2008 07:28:44 +0000 (07:28 +0000)
ui/ui.spinner.js

index 34f759982ba83fa7e8eda46dd2609efcd79b20b1..8486f3ecf266d69c209cb65917b60f6c3fca6a7a 100644 (file)
@@ -57,6 +57,9 @@ $.widget("ui.spinner", {
                        self.propagate("change", e);\r
                })\r
                ;\r
+               if ($.fn.mousewheel) {\r
+                       this.element.mousewheel(function(e, delta) { self.mousewheel(e, delta); });\r
+               }\r
 \r
        },\r
        plugins: {},\r
@@ -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\r
                if(e.keyCode == 35 && this.options.max != undefined) this.element[0].value = this.options.max; //End key goes to maximum\r
        },\r
+       mousewheel: function(e, delta) {\r
+               delta = ($.browser.opera ? -delta / Math.abs(delta) : delta);\r
+               delta > 0 ? this.up(e) : this.down(e);\r
+               e.preventDefault();\r
+       },\r
        ui: function(e) {\r
                return {\r
                        instance: this,\r
@@ -114,6 +122,9 @@ $.widget("ui.spinner", {
                        .removeClass("ui-spinner ui-spinner-disabled")\r
                        .removeData("spinner")\r
                        .unbind(".spinner");\r
+               if ($.fn.mousewheel) {\r
+                       this.element.unmousewheel();\r
+               }\r
        }\r
 });\r
 \r