Please note, this is a STATIC archive of website developer.mozilla.org from November 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Animation.finish()

Nossos voluntários ainda não traduziram este artigo para o Português (do Brasil) . Junte-se a nós e ajude a fazer o trabalho!

This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for usage in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the specification changes.

The Animation.finish() method of the Animation Interface seeks to either end of an animation, depending on whether the animation is playing or reversing.

Syntax

animation.finish(); 

Parameters

None.

Return Value

None.

Exceptions

An InvalidState error is raised if the player's playback rate is 0 or the animation's playback rate is greater than 0 and the end time of the animation is infinity.

Examples

The following example shows how to use the finish() method and catch an InvalidState error.

interfaceElement.addEventListener("mousedown", function() {
  try {
    player.finish();
  } catch(e if e instanceof InvalidState) {
    console.log("finish() called on paused or finished animation.");
  } catch(e);
    logMyErrors(e); //pass exception object to error handler
  }
});

The following example finishes all the animations on a single element, regardless of their direction of playback.

elem.getAnimations().forEach(
  function(animation){ 
    return animation.finish();
  }
);

Specifications

Specification Status Comment
Web Animations
The definition of 'finish()' in that specification.
Working Draft  

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 39.0 48 (48) No support No support No support
Feature Android Android Webview Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile Chrome for Android
Basic support No support 39.0 48.0 (48) No support No support No support 39.0

 

See also

Etiquetas do documento e colaboradores

 Colaboradores desta página: birtles, jpmedley, chrisdavidmills, rachelnabors, fscholz, teoli, kscarfone
 Última atualização por: birtles,