From 44de3d325c1ac0c4a841deff0ec03265a0b670f7 Mon Sep 17 00:00:00 2001 From: Michał Gołębiowski-Owczarek Date: Fri, 21 Mar 2025 00:03:17 +0100 Subject: Spinner: Prevent double mousewheel & wheel event handling As of gh-2338, if one has loaded the jQuery MouseWheel plugin, the `mousewheel` handler would fire the `wheel` one, but the `wheel` one would also run in response to the native `wheel` event, resulting in double the distance handled by the spinner. To prevent the issue, only fire the `wheel` handler from inside the `mousewheel` on if the event was triggered by jQuery - jQuery will not care that the underlying event is `wheel` and will only fire handlers for `mousewheel`. Also, add an iframe test using jQuery MouseWheel to not affect all the other tests. Plus, migrate from `QUnit.reset` to `QUnit.done` (see qunitjs/qunit#354). Closes gh-2342 Ref gh-2338 --- ui/widgets/spinner.js | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'ui/widgets/spinner.js') diff --git a/ui/widgets/spinner.js b/ui/widgets/spinner.js index 4fb41d7bb..d4034b458 100644 --- a/ui/widgets/spinner.js +++ b/ui/widgets/spinner.js @@ -164,6 +164,13 @@ $.widget( "ui.spinner", { // event. The `delta` parameter is provided by the jQuery Mousewheel // plugin if one is loaded. mousewheel: function( event, delta ) { + if ( !event.isTrigger ) { + + // If this is not a trigger call, the `wheel` handler will + // fire as well, let's not duplicate it. + return; + } + var wheelEvent = $.Event( event ); wheelEvent.type = "wheel"; if ( delta ) { -- cgit v1.2.3