AnimationPlayer

From Get docs
< @angular/animationsAngular/docs/9/api/animations/animationplayer


AnimationPlayer

interface

Provides programmatic control of a reusable animation sequence, built using the build() method of AnimationBuilder. The build() method returns a factory, whose create() method instantiates and initializes this interface.

interface AnimationPlayer {
  parentPlayer: AnimationPlayer | null
  totalTime: number
  beforeDestroy?: () => any
  onDone(fn: () => void): void
  onStart(fn: () => void): void
  onDestroy(fn: () => void): void
  init(): void
  hasStarted(): boolean
  play(): void
  pause(): void
  restart(): void
  finish(): void
  destroy(): void
  reset(): void
  setPosition(position: any): void
  getPosition(): number
}

Class implementations

  • NoopAnimationPlayer
    • MockAnimationPlayer


See also

  • AnimationBuilder
  • AnimationFactory
  • animate()

Properties

Property Description
null The parent of this player, if any.
totalTime: number

Read-Only The total run time of the animation, in milliseconds.

beforeDestroy?: () => any Provides a callback to invoke before the animation is destroyed.

Methods

Provides a callback to invoke when the animation finishes.

See also:

  • finish()

onDone(fn: () => void): void

Parameters
fn () => void The callback function.
Returns

void


Provides a callback to invoke when the animation starts.

See also:

  • run()

onStart(fn: () => void): void

Parameters
fn () => void The callback function.
Returns

void


Provides a callback to invoke after the animation is destroyed.

See also:

  • destroy()
  • beforeDestroy()

onDestroy(fn: () => void): void

Parameters
fn () => void The callback function.
Returns

void


Initializes the animation.

init(): void

Parameters

There are no parameters.

Returns

void


Reports whether the animation has started.

hasStarted(): boolean

Parameters

There are no parameters.

Returns

boolean: True if the animation has started, false otherwise.


Runs the animation, invoking the onStart() callback.

play(): void

Parameters

There are no parameters.

Returns

void


Pauses the animation.

pause(): void

Parameters

There are no parameters.

Returns

void


Restarts the paused animation.

restart(): void

Parameters

There are no parameters.

Returns

void


Ends the animation, invoking the onDone() callback.

finish(): void

Parameters

There are no parameters.

Returns

void


Destroys the animation, after invoking the beforeDestroy() callback. Calls the onDestroy() callback when destruction is completed.

destroy(): void

Parameters

There are no parameters.

Returns

void


Resets the animation to its initial state.

reset(): void

Parameters

There are no parameters.

Returns

void


Sets the position of the animation.

setPosition(position: any): void

Parameters
position any A 0-based offset into the duration, in milliseconds.
Returns

void


Reports the current position of the animation.

getPosition(): number

Parameters

There are no parameters.

Returns

number: A 0-based offset into the duration, in milliseconds.



© 2010–2020 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v9.angular.io/api/animations/AnimationPlayer