From d00106c8fd7d21493640ff094f8c4c7bcb237401 Mon Sep 17 00:00:00 2001 From: Vladimir Kharlampidi Date: Thu, 27 Jun 2019 13:03:33 +0300 Subject: [PATCH] Fix autoplay stopping after resize Fixes #3123 --- src/components/autoplay/autoplay.js | 1 + src/components/core/events/onResize.js | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/components/autoplay/autoplay.js b/src/components/autoplay/autoplay.js index 5b1063fbe..7ff300041 100644 --- a/src/components/autoplay/autoplay.js +++ b/src/components/autoplay/autoplay.js @@ -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) { diff --git a/src/components/core/events/onResize.js b/src/components/core/events/onResize.js index 14662a02a..31962ef8c 100644 --- a/src/components/core/events/onResize.js +++ b/src/components/core/events/onResize.js @@ -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) { @@ -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;