Skip to content

Commit

Permalink
Merge pull request davidjerleke#751 from davidjerleke/bug/davidjerlek…
Browse files Browse the repository at this point in the history
…e#750

[Bug]: Autoplay and AutoScroll not destroyed properly
  • Loading branch information
davidjerleke committed Feb 20, 2024
2 parents b04f0af + 44cc2ca commit 0926b15
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,15 @@ function AutoScroll(userOptions: AutoScrollOptionsType = {}): AutoScrollType {
}

function destroy(): void {
destroyed = true
playing = false
emblaApi
.off('init', startScroll)
.off('reInit', startScroll)
.off('pointerDown', stopScroll)
.off('pointerUp', startScrollOnSettle)
.off('settle', onSettle)
stopScroll()
destroyed = true
playing = false
}

function startScroll(): void {
Expand Down
4 changes: 2 additions & 2 deletions packages/embla-carousel-autoplay/src/components/Autoplay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,6 @@ function Autoplay(userOptions: AutoplayOptionsType = {}): AutoplayType {
}

function destroy(): void {
destroyed = true
playing = false
emblaApi
.off('init', startTimer)
.off('reInit', startTimer)
Expand All @@ -105,6 +103,8 @@ function Autoplay(userOptions: AutoplayOptionsType = {}): AutoplayType {
stopTimer()
cancelAnimationFrame(animationFrame)
animationFrame = 0
destroyed = true
playing = false
}

function startTimer(): void {
Expand Down

0 comments on commit 0926b15

Please sign in to comment.