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. }

参见

属性

属性说明
parentPlayer: AnimationPlayer | null

The parent of this player, if any.

totalTime: number 只读

The total run time of the animation, in milliseconds.

beforeDestroy?: () => any

Provides a callback to invoke before the animation is destroyed.

方法

Provides a callback to invoke when the animation finishes.

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

The callback function.

返回值

void

Provides a callback to invoke when the animation starts.

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

The callback function.

返回值

void

Provides a callback to invoke after the animation is destroyed.

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

The callback function.

返回值

void

Initializes the animation.

init(): void
      
      init(): void
    
参数

没有参数。

返回值

void

Reports whether the animation has started.

hasStarted(): boolean
      
      hasStarted(): boolean
    
参数

没有参数。

返回值

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

Runs the animation, invoking the onStart() callback.

play(): void
      
      play(): void
    
参数

没有参数。

返回值

void

Pauses the animation.

pause(): void
      
      pause(): void
    
参数

没有参数。

返回值

void

Restarts the paused animation.

restart(): void
      
      restart(): void
    
参数

没有参数。

返回值

void

Ends the animation, invoking the onDone() callback.

finish(): void
      
      finish(): void
    
参数

没有参数。

返回值

void

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

destroy(): void
      
      destroy(): void
    
参数

没有参数。

返回值

void

Resets the animation to its initial state.

reset(): void
      
      reset(): void
    
参数

没有参数。

返回值

void

Sets the position of the animation.

setPosition(position: any): void
      
      setPosition(position: any): void
    
参数
position any

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

返回值

void

Reports the current position of the animation.

getPosition(): number
      
      getPosition(): number
    
参数

没有参数。

返回值

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