Skip to content

Commit

Permalink
feat(navigation): add navigationPrev and navigationNext events
Browse files Browse the repository at this point in the history
fixes #5832
  • Loading branch information
nolimits4web committed Jun 29, 2022
1 parent 78a8d90 commit d0c6365
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/angular/src/swiper.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,10 @@ export class SwiperComponent implements OnInit {

@Output('navigationShow') s_navigationShow = new EventEmitter<EventsParams['navigationShow']>();

@Output('navigationPrev') s_navigationPrev = new EventEmitter<EventsParams['navigationPrev']>();

@Output('navigationNext') s_navigationNext = new EventEmitter<EventsParams['navigationNext']>();

@Output('observerUpdate') s_observerUpdate = new EventEmitter<EventsParams['observerUpdate']>();

@Output('orientationchange') s_orientationchange = new EventEmitter<
Expand Down
2 changes: 2 additions & 0 deletions src/modules/navigation/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,13 @@ export default function Navigation({ swiper, extendParams, on, emit }) {
e.preventDefault();
if (swiper.isBeginning && !swiper.params.loop && !swiper.params.rewind) return;
swiper.slidePrev();
emit('navigationPrev');
}
function onNextClick(e) {
e.preventDefault();
if (swiper.isEnd && !swiper.params.loop && !swiper.params.rewind) return;
swiper.slideNext();
emit('navigationNext');
}
function init() {
const params = swiper.params.navigation;
Expand Down
8 changes: 8 additions & 0 deletions src/types/modules/navigation.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ export interface NavigationEvents {
* Event will be fired on navigation show
*/
navigationShow: (swiper: Swiper) => void;
/**
* Event will be fired on navigation prev button click
*/
navigationPrev: (swiper: Swiper) => void;
/**
* Event will be fired on navigation next button click
*/
navigationNext: (swiper: Swiper) => void;
}

export interface NavigationOptions {
Expand Down
2 changes: 2 additions & 0 deletions src/vue/swiper.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ const Swiper = {
'momentumBounce',
'navigationHide',
'navigationShow',
'navigationPrev',
'navigationNext',
'observerUpdate',
'orientationchange',
'paginationHide',
Expand Down

0 comments on commit d0c6365

Please sign in to comment.