From 8ed00deec1fa95a97c40a0035bc6aa1a29f666c4 Mon Sep 17 00:00:00 2001 From: Vadim Date: Wed, 30 Jun 2021 23:37:48 +0300 Subject: [PATCH] Prevent disabling if not animated --- src/components/Carousel/Carousel.svelte | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/Carousel/Carousel.svelte b/src/components/Carousel/Carousel.svelte index 4e6e85a..1db0fbc 100644 --- a/src/components/Carousel/Carousel.svelte +++ b/src/components/Carousel/Carousel.svelte @@ -198,14 +198,16 @@ } } + // Disable page change while animation is in progress let disabled = false - function safeChangePage(cb) { + function safeChangePage(cb, options) { + const animated = get(options, 'animated', true) if (disabled) return cb() disabled = true setTimeout(() => { disabled = false - }, duration) + }, animated ? duration : 0) } function showPage(pageIndex, { offsetDelayMs, animated }) {