Skip to content

Commit

Permalink
fix(mousewheel): fix issue with event handling after Swiper was destr…
Browse files Browse the repository at this point in the history
…oyed

fixes #7654
  • Loading branch information
nolimits4web committed Jul 31, 2024
1 parent 4875f26 commit 82ae434
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/modules/mousewheel/mousewheel.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ export default function Mousewheel({ swiper, extendParams, on, emit }) {
lastEventBeforeSnap = newEvent;
recentWheelEvents.splice(0);
timeout = nextTick(() => {
if (swiper.destroyed || !swiper.params) return;
swiper.slideToClosest(swiper.params.speed, true, undefined, snapToThreshold);
}, 0); // no delay; move on next tick
}
Expand All @@ -371,6 +372,7 @@ export default function Mousewheel({ swiper, extendParams, on, emit }) {
// we'll consider a scroll "complete" when there haven't been any wheel events
// for 500ms.
timeout = nextTick(() => {
if (swiper.destroyed || !swiper.params) return;
const snapToThreshold = 0.5;
lastEventBeforeSnap = newEvent;
recentWheelEvents.splice(0);
Expand Down

0 comments on commit 82ae434

Please sign in to comment.