Hi there,
I’m trying to get some text to do the following:
-
slide in from the left
-
hold for a moment
-
slide out to the right
-
select the next text in the array
-
repeat
I used the example code at https://russian-dima.wixsite.com/meinewebsite/test-1 as a starting point, but that has a few issues that I’m not dealing with:
-
it does not have any transition effects, instead, it just changes the text
-
it uses buttons to turn the effect on/off
Here’s what I have so far, but if you try it, you’ll see that it’s not doing quite right. It appears that the change on the array is happening prior to the transition out and then it gets out of sync very fast. In addition, there’s a long delay at page load.
var i = 0
var counter=0
var myTimerValue = 3000
var myDelayTime = 1500
var myArray = ["Item 1", "Item 2", "Item 3", "Item 4", "Item 5", "Item 6", "Item 7"]
let myVar = setInterval(myFunction, myTimerValue);
let hideOptions = {
"duration": myTimerValue,
"direction" : "right"
};
let showOptions = {
"duration": myTimerValue,
"direction" : "left"
};
function myFunction() {console.log(counter++)
$w('#text01').hide()
$w('#text01').show('slide', showOptions)
if (myArray[i]===undefined) { i = 0,
$w('#text01').text="Item 0", stopFunction(), console.log("Function stopped")
setTimeout(()=>{myVar = setInterval(myFunction, myTimerValue)},myDelayTime)
}
else {
return $w('#text01').text=myArray[i], i = i+1
}
};
function stopFunction() {clearInterval(myVar);};
I’d love to get some thoughts on how to get this to work better.
Thank you in advance for your help,
Michael