Why does it disappear smoothly, but appears abruptly (transition: opasity)?
-
There is a block that, when the button is clicked, should fade out and appear thanks to js:
document.getElementsByTagName('div')[0].style.opacity = '0'; setTimeout(()=> { document.getElementsByTagName('div')[0].style.opacity = '1'; }, 1000);
div { transition: opacity 1s ease; }
<div> <p>Привет, стиль..</p> </div>
But it turns out that it only smoothly disappears, and appears - abruptly.
Please tell me how to fix this.JavaScript Anonymous, Aug 12, 2020 -
Either decrease the transit or increase the timeout. If the js changes the fear before the animation ends, then an instant transition is obtained.Juliet Weiss
1 Answers
Your Answer
To place the code, please use CodePen or similar tool. Thanks you!