diff --git a/src/components/autoplay/autoplay.js b/src/components/autoplay/autoplay.js index 7656a0677..346bf3b73 100644 --- a/src/components/autoplay/autoplay.js +++ b/src/components/autoplay/autoplay.js @@ -115,13 +115,21 @@ const Autoplay = { }, onMouseEnter() { const swiper = this; - swiper.autoplay.pause(); + if (swiper.params.autoplay.disableOnInteraction) { + swiper.autoplay.stop(); + } else { + swiper.autoplay.pause(); + } + ['transitionend', 'webkitTransitionEnd'].forEach((event) => { swiper.$wrapperEl[0].removeEventListener(event, swiper.autoplay.onTransitionEnd); }); }, onMouseLeave() { const swiper = this; + if (swiper.params.autoplay.disableOnInteraction) { + return; + } swiper.autoplay.paused = false; swiper.autoplay.run(); }, diff --git a/src/types/components/autoplay.d.ts b/src/types/components/autoplay.d.ts index a237bcd9c..86a6d911d 100644 --- a/src/types/components/autoplay.d.ts +++ b/src/types/components/autoplay.d.ts @@ -93,7 +93,7 @@ export interface AutoplayOptions { waitForTransition?: boolean; /** - * When enabled autoplay will be paused on mouse enter over Swiper container + * When enabled autoplay will be paused on mouse enter over Swiper container. If `disableOnInteraction` is also enabled, it will stop autoplay instead of pause * * @default false */