Skip to content
This repository has been archived by the owner on Sep 28, 2023. It is now read-only.

Commit

Permalink
add safe check to OCarouselContainerComponent to prevent throwing errors
Browse files Browse the repository at this point in the history
fix: when an event trigger on OCarouselContainerComponent before swiper being initialized, it throw errors
  this commit tries to prevent that by add safe checks to make sure that swiper is defined before it tries to stop/start the autoplay

fix #120
  • Loading branch information
Robert Isaac committed Oct 16, 2019
1 parent debd517 commit 9303eaf
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,22 +82,30 @@ import {
});
}
@HostListener('mouseenter') public onMouseEnter() {
this.swiper.autoplay.stop();
if (this.swiper) {
this.swiper.autoplay.stop();
}
this.pause = !this.pause;
}

@HostListener('mouseleave') public onMouseLeave() {
this.swiper.autoplay.start();
if (this.swiper) {
this.swiper.autoplay.start();
}
this.pause = !this.pause;
}

@HostListener('focus') public onFocusIn() {
this.swiper.autoplay.start();
if (this.swiper) {
this.swiper.autoplay.start();
}
this.pause = !this.pause;
}

@HostListener('blur') public onFocusOut() {
this.swiper.autoplay.start();
if (this.swiper) {
this.swiper.autoplay.start();
}
this.pause = !this.pause;
}
}

0 comments on commit 9303eaf

Please sign in to comment.