fix: run Toast first image change change after loop delay
This commit is contained in:
@@ -30,10 +30,11 @@
|
|||||||
// Image rotation
|
// Image rotation
|
||||||
let imagesLoop: ReturnType<typeof setTimeout>
|
let imagesLoop: ReturnType<typeof setTimeout>
|
||||||
let currentImageIndex = 0
|
let currentImageIndex = 0
|
||||||
|
const loopDuration = 3000
|
||||||
|
|
||||||
const incrementCurrentImageIndex = () => {
|
const incrementCurrentImageIndex = () => {
|
||||||
currentImageIndex = currentImageIndex === images.length - 1 ? 0 : currentImageIndex + 1
|
currentImageIndex = currentImageIndex === images.length - 1 ? 0 : currentImageIndex + 1
|
||||||
imagesLoop = setTimeout(() => requestAnimationFrame(incrementCurrentImageIndex), 3000)
|
imagesLoop = setTimeout(() => requestAnimationFrame(incrementCurrentImageIndex), loopDuration)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close toast
|
// Close toast
|
||||||
@@ -52,7 +53,7 @@
|
|||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
if (images.length > 1) {
|
if (images.length > 1) {
|
||||||
incrementCurrentImageIndex()
|
imagesLoop = setTimeout(incrementCurrentImageIndex, loopDuration)
|
||||||
}
|
}
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user