Currently I have a div that has the class "hidden" (css, display: none). I want it to add the class "full-size" after a set ammount of time with javascript. However, how can I implement a "flash in" function?
setTimeout(fade_out, 28000);
function fade_out() {
$("#interval").fadeOut().empty();
}
window.setTimeout(function() {
$("#main").fadeIn().addClass('full-size');
}, 28000);
Instead of "fadeIn()", is there something similar that gives a "White flash in" animation where it flashes you with a white color and then the white color fades out to reveal "#main"?
Sorry if this request is unreasonable, this’ll be my first time asking a question instead of using AI!! Figured that it might be a good opportunity 😀
I tried searching on google but really couldn’t find what I was searching for.
The best I got was a "repetitivily flashing, blinking" animation:
$("#someElement").fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100);
Which, unluckily, it isn’t what I was searching for 🙁
2
Answers
You can use CSS animation to this. Test the sample code. Hope it be helpful.
Change to flash once by editing CSS. animation:flasher 2s 1 linear; infinite –> 1
Change speed by editing CSS. animation:flasher 0.5s 1 linear; 2s –> 0.5s
Sample code:
If you really want to use JavaScript, use the Web Animation API, we don’t even have to use classes. It’s hard to be more concise than that.