Skip to content

Commit

Permalink
fix(autoplay): don't run autoplay if swiper is hidden
Browse files Browse the repository at this point in the history
fixes #5907
  • Loading branch information
nolimits4web committed Jul 26, 2022
1 parent 574572c commit 4f2e30f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/modules/autoplay/autoplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ export default function Autoplay({ swiper, extendParams, on, emit }) {
});

function run() {
if (!swiper.size) {
swiper.autoplay.running = false;
swiper.autoplay.paused = false;
return;
}
const $activeSlideEl = swiper.slides.eq(swiper.activeIndex);
let delay = swiper.params.autoplay.delay;
if ($activeSlideEl.attr('data-swiper-autoplay')) {
Expand Down

1 comment on commit 4f2e30f

@efraimKroizer
Copy link

@efraimKroizer efraimKroizer commented on 4f2e30f Aug 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change caused that in case that swiper is initialized before the element is rendered, autoplay through the params will not work, and a specific command is required when the elemnt rendered. This is a change that breaks existing behavior, and it is not correct to do this as part of a normal update

Please sign in to comment.