Skip to content

Commit

Permalink
fix a bug where slide event do not trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
cxFreeze committed Jun 28, 2024
1 parent 31db94c commit 1e17b8d
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/monthview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,9 @@ export class MonthViewComponent implements ICalendarComponent, OnInit, OnDestroy
ngAfterViewInit() {
this.slider = new Swiper(this.swiperElement?.nativeElement, this.sliderOptions);
let me = this;
this.slider.on('slideNextTransitionEnd', function() {
me.onSlideChanged(1);
});

this.slider.on('slidePrevTransitionEnd', function() {
me.onSlideChanged(-1);
this.slider.on('transitionEnd', function(event) {
me.onSlideChanged(event.realIndex);
});

if(this.dir == 'rtl') {
Expand All @@ -221,8 +218,12 @@ export class MonthViewComponent implements ICalendarComponent, OnInit, OnDestroy
this.slider = swiper;
}

onSlideChanged(direction: number) {
this.currentViewIndex = (this.currentViewIndex + direction + 3) % 3;
onSlideChanged(newViewIndex: number) {
if (newViewIndex === this.currentViewIndex) {
return;
}
const direction = (newViewIndex === (this.currentViewIndex + 1) % 3) ? 1 : -1;
this.currentViewIndex = newViewIndex;
this.move(direction);
}

Expand Down

1 comment on commit 1e17b8d

@cxFreeze
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix issue

Please sign in to comment.