- This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
Viewing 4 posts - 1 through 4 (of 4 total)
- The forum ‘JavaScript’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › JavaScript › Fade Effect
http://codepen.io/gsg/pen/zxxNPv
How do you delay the removing part of the.fade
class in a more elegant way? I used setTimeout
method but isn’t a smooth effect.
Thanks!
I’m thinking what you are actually after is two effects..one to fade out the existing text and another to fade it in.
What you have now, when the class is applied, is it jumping immediately to 0 opacity and then fading in.
Also, you’re changing the text as soon as the class is applied…without enough time for the fade to complete the transition to 0.
So what I think you want is start the fade out…at the point the opacity is 0 (say 50% through the cycle) change the text and then fade it back in again.
So…we change the animation to start at 1, be 0 by 50% and then back to 1.
Add a setTimeout to the text change so it occurs halfway through the animation and increase the timeOut of the class toggle to be at the end.