Help Angular by taking a 1 minute survey!Go to surveyHome

AnimationPlayer

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.

      
      
  1. interface AnimationPlayer {
  2. parentPlayer: AnimationPlayer | null
  3. totalTime: number
  4. beforeDestroy?: () => any
  5. onDone(fn: () => void): void
  6. onStart(fn: () => void): void
  7. onDestroy(fn: () => void): void
  8. init(): void
  9. hasStarted(): boolean
  10. play(): void
  11. pause(): void
  12. restart(): void
  13. finish(): void
  14. destroy(): void
  15. reset(): void
  16. setPosition(position: any): void
  17. getPosition(): number
  18. }

See also

Properties

Property Description
parentPlayer: AnimationPlayer | 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
      
      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
      
      onStart(fn: () => void): void
    
Parameters
fn () => void

The callback function.

Returns

void

Provides a callback to invoke after the animation is destroyed.

See also:

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

The callback function.

Returns

void

Initializes the animation.

init(): void
      
      init(): void
    
Parameters

There are no parameters.

Returns

void

Reports whether the animation has started.

hasStarted(): boolean
      
      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
      
      play(): void
    
Parameters

There are no parameters.

Returns

void

Pauses the animation.

pause(): void
      
      pause(): void
    
Parameters

There are no parameters.

Returns

void

Restarts the paused animation.

restart(): void
      
      restart(): void
    
Parameters

There are no parameters.

Returns

void

Ends the animation, invoking the onDone() callback.

finish(): void
      
      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
      
      destroy(): void
    
Parameters

There are no parameters.

Returns

void

Resets the animation to its initial state.

reset(): void
      
      reset(): void
    
Parameters

There are no parameters.

Returns

void

Sets the position of the animation.

setPosition(position: any): void
      
      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
      
      getPosition(): number
    
Parameters

There are no parameters.

Returns

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