Animation.commitStyles()
The commitStyles()
method of the Web Animations API's Animation
interface commits the end styling state of an animation to the element being animated, even after that animation has been removed. It will cause the end styling state to be written to the element being animated, in the form of properties inside a style
attribute.
Syntax
animation.commitStyles();
Parameters
None.
Return value
None.
Examples
const divElem = document.querySelector('div');
document.body.addEventListener('mousemove', evt => {
let anim = divElem.animate(
{ transform: `translate(${ evt.clientX}px, ${evt.clientY}px)` },
{ duration: 500, fill: 'forwards' }
);
anim.commitStyles();
});
Specifications
Specification |
---|
Web Animations # dom-animation-commitstyles |
Browser compatibility
BCD tables only load in the browser
See also
- Web Animations API
Animation
for other methods and properties you can use to control web page animation.