Skip to content

Commit

Permalink
Merge pull request #30 from BKWLD/autoplay-infinite
Browse files Browse the repository at this point in the history
add simple go to start for autoplay
  • Loading branch information
weotch authored Feb 1, 2022
2 parents 28cd7b3 + dacfa37 commit 6562280
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/concerns/autoplay.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,15 @@ export default

methods:
autoplayStart: ->
# Don't loop if we only have one page
return if @pages <= 0

if @autoplayDelay then @autoPlayInterval = setInterval (() =>
@next() if not @autoplayPaused
@autoplayNext() if not @autoplayPaused
), @autoplayDelay * 1000

autoplayStop: -> clearInterval @autoPlayInterval

autoplayNext: ->
nextIndex = @index + 1
if nextIndex < @pages then @next() else @goto 0

0 comments on commit 6562280

Please sign in to comment.