Skip to content

Commit

Permalink
fix(autoplay): correct support for virtual slides delay + fix for sto…
Browse files Browse the repository at this point in the history
…pping autoplay on click
  • Loading branch information
nolimits4web committed Dec 7, 2022
1 parent 59da65c commit 43bf429
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/modules/autoplay/autoplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,16 @@ export default function Autoplay({ swiper, extendParams, on, emit, params }) {
};

const getSlideDelay = () => {
const currentSlideDelay = parseInt(
swiper.slides[swiper.activeIndex].getAttribute('data-swiper-autoplay'),
10,
);
let activeSlideEl;
if (swiper.virtual && swiper.params.virtual.enabled) {
activeSlideEl = swiper.slides.filter((slideEl) =>
slideEl.classList.contains('swiper-slide-active'),
)[0];
} else {
activeSlideEl = swiper.slides[swiper.activeIndex];
}
if (!activeSlideEl) return undefined;
const currentSlideDelay = parseInt(activeSlideEl.getAttribute('data-swiper-autoplay'), 10);
return currentSlideDelay;
};

Expand Down Expand Up @@ -279,11 +285,11 @@ export default function Autoplay({ swiper, extendParams, on, emit, params }) {
});

on('touchEnd', () => {
if (swiper.destroyed || !swiper.autoplay.running) return;
if (swiper.destroyed || !swiper.autoplay.running || !isTouched) return;
clearTimeout(touchStartTimeout);
clearTimeout(timeout);

if (!isTouched || swiper.params.autoplay.disableOnInteraction) {
if (swiper.params.autoplay.disableOnInteraction) {
pausedByTouch = false;
isTouched = false;
return;
Expand Down

0 comments on commit 43bf429

Please sign in to comment.