Skip to content

Commit 82ae434

Browse files
committed
fix(mousewheel): fix issue with event handling after Swiper was destroyed
fixes #7654
1 parent 4875f26 commit 82ae434

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/modules/mousewheel/mousewheel.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ export default function Mousewheel({ swiper, extendParams, on, emit }) {
363363
lastEventBeforeSnap = newEvent;
364364
recentWheelEvents.splice(0);
365365
timeout = nextTick(() => {
366+
if (swiper.destroyed || !swiper.params) return;
366367
swiper.slideToClosest(swiper.params.speed, true, undefined, snapToThreshold);
367368
}, 0); // no delay; move on next tick
368369
}
@@ -371,6 +372,7 @@ export default function Mousewheel({ swiper, extendParams, on, emit }) {
371372
// we'll consider a scroll "complete" when there haven't been any wheel events
372373
// for 500ms.
373374
timeout = nextTick(() => {
375+
if (swiper.destroyed || !swiper.params) return;
374376
const snapToThreshold = 0.5;
375377
lastEventBeforeSnap = newEvent;
376378
recentWheelEvents.splice(0);

0 commit comments

Comments
 (0)