From 7ace64b0a1fa8d69469a2282dff0fa80e603afc0 Mon Sep 17 00:00:00 2001 From: Vadim Date: Sat, 3 Jul 2021 14:02:39 +0300 Subject: [PATCH] #31 : Fix autoplay progress for non infinite case --- src/components/Carousel/Carousel.svelte | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/Carousel/Carousel.svelte b/src/components/Carousel/Carousel.svelte index 5d8d303..0048f93 100644 --- a/src/components/Carousel/Carousel.svelte +++ b/src/components/Carousel/Carousel.svelte @@ -174,7 +174,13 @@ } function applyAutoplay() { - if (!infinite && currentPageIndex === pagesCount - 1) { + // prevent progress change if not infinite for first and last page + if ( + !infinite && ( + (autoplayDirection === NEXT && currentPageIndex === pagesCount - 1) || + (autoplayDirection === PREV && currentPageIndex === 0) + ) + ) { progressManager.reset() return }