Skip to content

Commit

Permalink
fix(autoplay): fix pauseOnPointerEnter if hovered during transition
Browse files Browse the repository at this point in the history
fixes #7107
  • Loading branch information
nolimits4web committed Oct 18, 2023
1 parent 8bef84d commit 5080d95
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/modules/autoplay/autoplay.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,15 @@ export default function Autoplay({ swiper, extendParams, on, emit, params }) {
let touchStartTimeout;
let slideChanged;
let pausedByInteraction;
let pausedByPointerEnter;

function onTransitionEnd(e) {
if (!swiper || swiper.destroyed || !swiper.wrapperEl) return;
if (e.target !== swiper.wrapperEl) return;
swiper.wrapperEl.removeEventListener('transitionend', onTransitionEnd);
if (pausedByPointerEnter) {
return;
}
resume();
}

Expand Down Expand Up @@ -212,12 +216,14 @@ export default function Autoplay({ swiper, extendParams, on, emit, params }) {
const onPointerEnter = (e) => {
if (e.pointerType !== 'mouse') return;
pausedByInteraction = true;
pausedByPointerEnter = true;
if (swiper.animating || swiper.autoplay.paused) return;
pause(true);
};

const onPointerLeave = (e) => {
if (e.pointerType !== 'mouse') return;
pausedByPointerEnter = false;
if (swiper.autoplay.paused) {
resume();
}
Expand Down

0 comments on commit 5080d95

Please sign in to comment.