Skip to content

Commit

Permalink
feat(autoplay): autoplayPause and autoplayResume events
Browse files Browse the repository at this point in the history
  • Loading branch information
nolimits4web committed Jan 28, 2022
1 parent 1288271 commit aea56ed
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/angular/src/swiper.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,14 @@ export class SwiperComponent implements OnInit {
Parameters<SwiperEvents['autoplayStop']>
>();

@Output('autoplayPause') s_autoplayPause = new EventEmitter<
Parameters<SwiperEvents['autoplayPause']>
>();

@Output('autoplayResume') s_autoplayResume = new EventEmitter<
Parameters<SwiperEvents['autoplayResume']>
>();

@Output('beforeDestroy') s_beforeDestroy = new EventEmitter<
Parameters<SwiperEvents['beforeDestroy']>
>();
Expand Down
2 changes: 2 additions & 0 deletions src/modules/autoplay/autoplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ export default function Autoplay({ swiper, extendParams, on, emit }) {
if (swiper.params.autoplay.disableOnInteraction) {
stop();
} else {
emit('autoplayPause');
pause();
}

Expand All @@ -143,6 +144,7 @@ export default function Autoplay({ swiper, extendParams, on, emit }) {
return;
}
swiper.autoplay.paused = false;
emit('autoplayResume');
run();
}
function attachMouseEvents() {
Expand Down
8 changes: 8 additions & 0 deletions src/types/modules/autoplay.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ export interface AutoplayEvents {
* Event will be fired when autoplay stopped
*/
autoplayStop: (swiper: Swiper) => void;
/**
* Event will be fired on autoplay pause (on mouse/pointer enter), when `pauseOnMouseEnter` enabled
*/
autoplayPause: (swiper: Swiper) => void;
/**
* Event will be fired on autoplay resume (on mouse/pointer leave), when `pauseOnMouseEnter` enabled
*/
autoplayResume: (swiper: Swiper) => void;
/**
* Event will be fired when slide changed with autoplay
*/
Expand Down
2 changes: 2 additions & 0 deletions src/vue/swiper.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ const Swiper = {
'autoplay',
'autoplayStart',
'autoplayStop',
'autoplayPause',
'autoplayResume',
'beforeDestroy',
'beforeInit',
'beforeLoopFix',
Expand Down

0 comments on commit aea56ed

Please sign in to comment.