I want some elements appear or disappear after some seconds when pages load.
Is it possible? How can it be achieved?
Sure, that’s easy.
In the $w.onReady use the setTimeout function to schedule something to happen later, after the timeout you specify. Then, in the setTimeout callback user the show and hide functions to make things appear and disappear
How should the code look like?
setTimeout(()=>{...here your code...},5000) //<-5sec.-Time-out
You should take a look at this url…
https://www.w3schools.com/jsref/met_win_setinterval.asp
Here an example…
https://russian-dima.wixsite.com/meinewebsite/test-1
var i = 0
var myTimerValue = 3000
var myArray = ["fast", "expensive", "useful", "a womanizer", "super-fast", "economic", "a monster"]
var myVar = setInterval(myFunction, myTimerValue);
$w.onReady(function () { })
export function BTNplay_click(event) {myFunction()}
export function BTNstop_click(event) {stopFunction()}
function myFunction() {
if (myArray[i]===undefined) {$w('#text1').text="END", stopFunction(), console.log("Function stopped")}
return $w('#text1').text=myArray[i], i = i+1}
function stopFunction() {clearInterval(myVar);}
@russian-dima , Wow! This is cool. Is it possible to loop this so it doesn’t stop? Because your example stops after about a minute. - Thanks.
@arthurvalatin
Normaly it should stop after the last item in the array was selected/showed.
I would have to take a look at this again. I remember that not everything was working fine in this code.
Do you want to make a loop ?
@russian-dima , yes! Is it possible? It would be fun to see it live!
Everything is possible when you work on it you lazy kid ^^
Normaly you should also be able to do it on your own, i know that you are experienced enough for this.
@russian-dima , ok I can’t cheat this time ^^. I will just have to get cracking.
@arthurvalatin
Everything you need is in the example right now! You little cracker xD
I need my text to appear after 6 seconds after and and stay like that for 6 seconds and then disappear, can any one code it for me​:grinning:
This Wix Velo Forum will help you to reach your goal with help and assistance with any code issues that you have, along with pointing you in the right direction with regards to using the correct Wix API or an example that you can see how it all works yourself.
What the forum won’t do is to sit down and write code for you, if you are after something like that then you are much better off checking out the Wix Marketplace and finding somebody suitable there.
Finally, have a read of our guidelines at the top of the forum, so that you know what to expect.