fix: run Toast first image change change after loop delay
This commit is contained in:
@@ -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 () => {
|
||||
|
||||
Reference in New Issue
Block a user