Skip to content

Commit

Permalink
feat(autoplay): if disableOnInteraction and pauseOnMouseEnter, it…
Browse files Browse the repository at this point in the history
… will stop autoplay on interaction

fixes #4598
  • Loading branch information
nolimits4web committed May 31, 2021
1 parent ff53797 commit e7e5031
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/components/autoplay/autoplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
},
Expand Down
2 changes: 1 addition & 1 deletion src/types/components/autoplay.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down

0 comments on commit e7e5031

Please sign in to comment.