From dacfa37dfe34e5be16e9474a94593e779f77f22a Mon Sep 17 00:00:00 2001 From: Sam Stark Date: Tue, 1 Feb 2022 14:33:50 -0500 Subject: [PATCH] add simple go to start for autoplay --- src/concerns/autoplay.coffee | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/concerns/autoplay.coffee b/src/concerns/autoplay.coffee index 839c5ff..ae0f56b 100644 --- a/src/concerns/autoplay.coffee +++ b/src/concerns/autoplay.coffee @@ -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