I'm having a really hard time figuring out how to start and stop an animation and reverse it.
I've assigned an animation to the element.style.animation property and from what I've read, I decided to use:
element.style.animationPlayState = "running";
to start it and:
element.style.animationPlayState = "paused";
to stop it.
But it reports "running" all the time.
Has anyone figured out how to start and stop an animation?
I have a related question here. The related part is this block of code that I use to make animations start and stop:
var style = element.style;
var animation = null;
style.animationPlayState = "paused";
if (style.animation) {
    animation = style.animation;
    style.animation = null;
    style.animationPlayState = "paused";
    element.addEventListener("animationend", function(event) {
        log("animation ended");
        element.removeEventListener("animationend", arguments.callee);
    });
    setTimeout(function() {
        style.animation = animation;
        style.animationPlayState = "paused";
        style.animationDirection = "reverse";
        style.animationPlayState = "running";
    }, 30);
}
The goal is simple:
- Display a divwhen user presses button
- divdisplay is none, so set it to- display: block
- Fade in div
- LATER - user presses a close button on div
- Fade out div
- After fade out set display: none
A method to do something like this:
fadeInElement(element)
fadeOutElement(element) 
 
     
     
    