Hello. I have 3 different sentences that i need to fade in / out in the same place one after the other; 5sec delay-
the last sentence should remain with a button. I'm trying the code:
let fadeOptions = {
"duration": 4000,
"delay": 1000
};
$w("#text26").hide("fade", fadeOptions);
and it works just for my first object. how can y make it work for multiple objects? please help Website link: https://nina9487.wixsite.com/pontem now is just working on one sentence.
What is your main goal for doing this? What is the for loop for? Do you want to create an infinite fade loop (in and out)?
If so, you can use Wix Animation to create this effect, not saying that you can't create it with code, it's just that you don't have to.
Here's an example:
import wixAnimations from 'wix-animations'; // Define the animation timeline. const fadeTimeline = wixAnimations.timeline({ repeat: -1, // Repeat the animation for ever. repeatDelay: 1000 * 3, // The time between each successful animation yoyo: true // Reverse the animation when it's done - fade in and out. }); // The element that we want to animate const element = $w('#image'); // Animations const fadeAnimation = { opacity: 0, duration: 700 // In milliseconds }; // Apply the animation on the above element using the timeline created above fadeTimeline.add(element, fadeAnimation);
Hope this helps~!
Ahmad
@Velo-Ninja what if I have three sentences and I want them to fade in fade out one by one and keep doing that infinite times. Can you help me with a code for that?
You could also use another structure... like this....
setTimeout(()=>{ sentence1.hide('fade'), sentence2.show('fade') setTimeout(()=>{ sentence2.hide('flip'), sentence3.show('flip') setTimeout(()=>{ sentence3.hide('float'), myButton.show('bounce') },5000) },5000) },5000)
There are probably more efficient solutions to generate this, but these are surely the fastest 😁
You will need this one....
setTimeout(()=>{ },500)
Put your code between the 2-curly brakets, which should have a delay of 5-secs.
5-secs = 500 milli-secs