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.
Deprecation warning
API
interface AnimationPlayer {
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;
parentPlayer: AnimationPlayer | null;
readonly totalTime: number;
beforeDestroy?: (() => any) | undefined;
}
onDone
voidProvides a callback to invoke when the animation finishes.
() => voidThe callback function.
void
onStart
voidProvides a callback to invoke when the animation starts.
() => voidThe callback function.
void
onDestroy
voidProvides a callback to invoke after the animation is destroyed.
() => voidThe callback function.
void
init
voidInitializes the animation.
void
hasStarted
booleanReports whether the animation has started.
boolean
play
voidRuns the animation, invoking the onStart() callback.
void
pause
voidPauses the animation.
void
restart
voidRestarts the paused animation.
void
finish
voidEnds the animation, invoking the onDone() callback.
void
destroy
voidDestroys the animation, after invoking the beforeDestroy() callback. Calls the onDestroy() callback when destruction is completed.
void
reset
voidResets the animation to its initial state.
void
setPosition
voidSets the position of the animation.
numberA fractional value, representing the progress through the animation.
void
getPosition
numberReports the current position of the animation.
number
parentPlayer
AnimationPlayer | nullThe parent of this player, if any.
totalTime
numberThe total run time of the animation, in milliseconds.
beforeDestroy
(() => any) | undefinedProvides a callback to invoke before the animation is destroyed.