Skip to content

Commit

Permalink
Bug fix for #1082.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidjerleke committed Jan 7, 2025
1 parent 1b01939 commit 6727eed
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/embla-carousel-autoplay/src/components/Autoplay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function Autoplay(userOptions: AutoplayOptionsType = {}): AutoplayType {
eventStore.add(emblaApi.containerNode(), 'focusout', startAutoplay)
}

if (options.playOnInit && !documentIsHidden()) startAutoplay()
if (options.playOnInit) startAutoplay()
}

function destroy(): void {
Expand Down Expand Up @@ -124,6 +124,10 @@ function Autoplay(userOptions: AutoplayOptionsType = {}): AutoplayType {

function startAutoplay(): void {
if (destroyed) return
if (documentIsHidden()) {
playOnDocumentVisible = true
return
}
if (!autoplayActive) emblaApi.emit('autoplay:play')

setTimer()
Expand Down

0 comments on commit 6727eed

Please sign in to comment.