Skip to content

Commit

Permalink
Carousel - Fix destroy listener
Browse files Browse the repository at this point in the history
  • Loading branch information
papegaill committed Apr 13, 2022
1 parent 086d6df commit 37b6c85
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/implementations/vanilla/components/carousel/carousel.js
Expand Up @@ -186,14 +186,14 @@ export class Carousel {
this.cloneFirstSLide.remove();
this.cloneLastSLide.remove();
}
if (this.attachClickListener && this.toggle) {
this.toggle.removeEventListener('click', this.handleClickOnToggle);
if (this.toggle) {
this.toggle.replaceWith(this.toggle.cloneNode(true));
}
if (this.attachClickListener && this.btnNext) {
this.btnNext.removeEventListener('click', this.shiftSlide);
this.btnNext.replaceWith(this.btnNext.cloneNode(true));
}
if (this.attachClickListener && this.btnPrev) {
this.btnPrev.removeEventListener('click', this.shiftSlide);
this.btnPrev.replaceWith(this.btnPrev.cloneNode(true));
}
if (this.slidesContainer) {
this.slidesContainer.removeEventListener('touchstart', this.dragStart);
Expand All @@ -206,7 +206,7 @@ export class Carousel {
}
if (this.navigationItems) {
this.navigationItems.forEach((nav) => {
nav.removeEventListener('click', this.shiftSlide);
nav.replaceWith(nav.cloneNode(true));
});
}
if (this.attachResizeListener) {
Expand Down

0 comments on commit 37b6c85

Please sign in to comment.