fix: run Toast first image change change after loop delay

This commit is contained in:
2023-06-11 22:47:53 +02:00
parent 8a81515135
commit f70c9d4997

View File

@@ -30,10 +30,11 @@
// Image rotation
let imagesLoop: ReturnType<typeof setTimeout>
let currentImageIndex = 0
const loopDuration = 3000
const incrementCurrentImageIndex = () => {
currentImageIndex = currentImageIndex === images.length - 1 ? 0 : currentImageIndex + 1
imagesLoop = setTimeout(() => requestAnimationFrame(incrementCurrentImageIndex), 3000)
imagesLoop = setTimeout(() => requestAnimationFrame(incrementCurrentImageIndex), loopDuration)
}
// Close toast
@@ -52,7 +53,7 @@
onMount(() => {
if (images.length > 1) {
incrementCurrentImageIndex()
imagesLoop = setTimeout(incrementCurrentImageIndex, loopDuration)
}
return () => {