diff options
author | Michał Gołębiowski-Owczarek <m.goleb@gmail.com> | 2025-03-18 11:45:00 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-18 11:45:00 +0100 |
commit | 6843ced12e4051aefbee47cf87fa79794737eb8a (patch) | |
tree | 267c0ae0d63a7b607c408a9223795c020ba4f74d /ui | |
parent | ef28a5f57036e32a66e6d469e345d7376ecdaffc (diff) | |
download | jquery-ui-6843ced12e4051aefbee47cf87fa79794737eb8a.tar.gz jquery-ui-6843ced12e4051aefbee47cf87fa79794737eb8a.zip |
Spinner: Drop dependency on jQuery Mousewheel
1. Listen to the native `wheel` event without depending on any wrapper plugins.
2. Keep listening to the `mousewheel` event for compatibility with projects
using the jQuery Mousewheel plugin but route it to the `wheel` handler.
Closes gh-2338
Diffstat (limited to 'ui')
-rw-r--r-- | ui/widgets/spinner.js | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/ui/widgets/spinner.js b/ui/widgets/spinner.js index d999d85d7..4fb41d7bb 100644 --- a/ui/widgets/spinner.js +++ b/ui/widgets/spinner.js @@ -136,9 +136,10 @@ $.widget( "ui.spinner", { this._trigger( "change", event ); } }, - mousewheel: function( event, delta ) { + wheel: function( event ) { var activeElement = this.document[ 0 ].activeElement; var isActive = this.element[ 0 ] === activeElement; + var delta = event.deltaY || event.originalEvent && event.originalEvent.deltaY; if ( !isActive || !delta ) { return; @@ -148,7 +149,7 @@ $.widget( "ui.spinner", { return false; } - this._spin( ( delta > 0 ? 1 : -1 ) * this.options.step, event ); + this._spin( ( delta > 0 ? -1 : 1 ) * this.options.step, event ); clearTimeout( this.mousewheelTimer ); this.mousewheelTimer = this._delay( function() { if ( this.spinning ) { @@ -157,6 +158,20 @@ $.widget( "ui.spinner", { }, 100 ); event.preventDefault(); }, + + // DEPRECATED + // Kept for backwards compatibility. Please use the modern `wheel` + // event. The `delta` parameter is provided by the jQuery Mousewheel + // plugin if one is loaded. + mousewheel: function( event, delta ) { + var wheelEvent = $.Event( event ); + wheelEvent.type = "wheel"; + if ( delta ) { + wheelEvent.deltaY = -delta; + } + return this._events.wheel.call( this, wheelEvent ); + }, + "mousedown .ui-spinner-button": function( event ) { var previous; |