bendc / animateplus

A+ animation module for the modern web
MIT License
5.96k stars 279 forks source link

Clear styles when animation is finnished. #13

Closed tomtev closed 8 years ago

tomtev commented 8 years ago

Hi, I can see that on the Stripe site the animation styles get removed from the style tag when the animation is finished. Is there an option for this?

bendc commented 8 years ago

You can use the complete callback to clear the inline styles at the end of the animation:

animate({
  el: "div",
  translateX: 200,
  complete: arr => arr.forEach(el => el.removeAttribute("style"))
});

That being said, removing the styles will obviously cancel the transformation applied (so, in this example, the divs will come back to translateX 0).