MDN self-hosted library · e01.org

Animation: finish() method

Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.

js
interfaceElement.addEventListener("mousedown", () => {
  try {
    player.finish();
  } catch (e) {
    if (e instanceof InvalidState) {
      console.log("finish() called on paused or finished animation.");
    } else {
      logMyErrors(e); // Pass exception object to error handler
    }
  }
});
js
elem.getAnimations().forEach((animation) => animation.finish());