4

On the end of an animation attached to #profile I would like to start the animation attached to #design how would I change the external css attached to #design from animation play-state: paused; to animation play state: running; using the event listener (see below). Im stuck on the next part (after ("design"). Any help appreciated.

document.getElementById("profile").addEventListener("webkitAnimationEnd", function(){ 
var animation = document.getElementById("design")

1 Answer 1

3

Extend your code to use the style object property animationPlayState in JavaScript. You need not use webkitAnimationEnd event anymore, since animationend event is supported cross-browser now.

var animation = document.getElementById("design");
var profile = document.getElementById("profile");
profile.addEventListener("animationend", function() {
  animation.style.animationPlayState = "running";
});
#profile,
#design {
  animation: moveRight;
  animation-duration: 2s;
}
#design {
  animation-play-state: paused;
}
@keyframes moveRight {
  from {
    margin-left: 0;
  }
  to {
    margin-left: 100px;
  }
}
<div id="profile">Profile</div>
<div id="design">Design</div>

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.