Stateful Animation Summary
- Can you tell from the event, which one of the keyframes have finished?
As far as she knows, no? You need to check the final value to know...
Web Animation API should know.
She's writing the MDN web animation documentation.
Upon checking the MDN documentation, she discovers, that you can get the
AnimationEvent.animationName
from the Web Animation API!So the previous solution would look like:
(jQuery steals the
event
so you have to add e.originalEvent
to get back to the original DOM event.)
// Attach a animationend event listener to #tuna
$("#tuna").on("animationend", function(e){
if(e.originalEvent.animationName === "walk-cycle") {
$("#tuna").addClass("sit");
}
});