Cookies concent notice

This site uses cookies from Google to deliver its services and to analyze traffic.
Learn more
Skip to main content
Say hello to Angular's future home!Check out Angular.devHome
/

AnimationPlayer

Provides programmatic control of a reusable animation sequence, built using the AnimationBuilder.build() method which returns an AnimationFactory, 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: number): void
  getPosition(): number
}
    

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:

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

The callback function.

Returns

void

Provides a callback to invoke when the animation starts.

See also:

      
      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
    
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: number): void
    
Parameters
position number

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.