bougarfaoui / ui-carousel

🎨 Angular carousel Component 🔥
https://bougarfaoui.github.io/ui-carousel/
MIT License
79 stars 53 forks source link

Unsubscribe on OnDestroy #24

Open pegamon opened 5 years ago

pegamon commented 5 years ago

There is missing unsubscribe in OnDestroy of ui-carousel.component. When carousel is in autoplay mode error occurs every set interval.

Very dirty hotfix by bold in ui-carousel/ui-carousel.component.js: UICarouselComponent.prototype.ngOnDestroy = function () { this.nextSubject.unsubscribe(); this.prevSubject.unsubscribe(); clearInterval(this.interval); }

This is only to show, where is problem . :)

Hotfix in application is to set up ui-carousel autoplay=false before OnDestroy is called.

jmcomby commented 5 years ago

Thx for the hint. Added in my Component: import { UICarouselComponent } from 'ui-carousel/dist/src/ui-carousel/ui-carousel.component' ... @ViewChild('carousel') private uicarousel: UICarouselComponent; ... ngOnDestroy(): void { clearInterval(this.uicarousel.interval); } Fix the error.