Skip to content

Commit

Permalink
Fix autoplay stopping after resize
Browse files Browse the repository at this point in the history
  • Loading branch information
nolimits4web committed Jun 27, 2019
1 parent 299cf4b commit d00106c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/components/autoplay/autoplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const Autoplay = {
if ($activeSlideEl.attr('data-swiper-autoplay')) {
delay = $activeSlideEl.attr('data-swiper-autoplay') || swiper.params.autoplay.delay;
}
clearTimeout(swiper.autoplay.timeout);
swiper.autoplay.timeout = Utils.nextTick(() => {
if (swiper.params.autoplay.reverseDirection) {
if (swiper.params.loop) {
Expand Down
4 changes: 4 additions & 0 deletions src/components/core/events/onResize.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export default function () {
if (params.autoHeight) {
swiper.updateAutoHeight();
}

} else {
swiper.updateSlidesClasses();
if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !swiper.params.centeredSlides) {
Expand All @@ -37,6 +38,9 @@ export default function () {
swiper.slideTo(swiper.activeIndex, 0, false, true);
}
}
if (swiper.autoplay && swiper.autoplay.running && swiper.autoplay.paused) {
swiper.autoplay.run();
}
// Return locks after resize
swiper.allowSlidePrev = allowSlidePrev;
swiper.allowSlideNext = allowSlideNext;
Expand Down

0 comments on commit d00106c

Please sign in to comment.