Skip to content

Commit e7e5031

Browse files
committed
feat(autoplay): if disableOnInteraction and pauseOnMouseEnter, it will stop autoplay on interaction
fixes #4598
1 parent ff53797 commit e7e5031

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/components/autoplay/autoplay.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,21 @@ const Autoplay = {
115115
},
116116
onMouseEnter() {
117117
const swiper = this;
118-
swiper.autoplay.pause();
118+
if (swiper.params.autoplay.disableOnInteraction) {
119+
swiper.autoplay.stop();
120+
} else {
121+
swiper.autoplay.pause();
122+
}
123+
119124
['transitionend', 'webkitTransitionEnd'].forEach((event) => {
120125
swiper.$wrapperEl[0].removeEventListener(event, swiper.autoplay.onTransitionEnd);
121126
});
122127
},
123128
onMouseLeave() {
124129
const swiper = this;
130+
if (swiper.params.autoplay.disableOnInteraction) {
131+
return;
132+
}
125133
swiper.autoplay.paused = false;
126134
swiper.autoplay.run();
127135
},

src/types/components/autoplay.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export interface AutoplayOptions {
9393
waitForTransition?: boolean;
9494

9595
/**
96-
* When enabled autoplay will be paused on mouse enter over Swiper container
96+
* When enabled autoplay will be paused on mouse enter over Swiper container. If `disableOnInteraction` is also enabled, it will stop autoplay instead of pause
9797
*
9898
* @default false
9999
*/

0 commit comments

Comments
 (0)