onStart( )

Sets an event handler that runs when the timeline starts playing.

The event handler set by calling the onStart() function runs when a timeline starts playing from the beginning.

This happens when:

  • The play() function is called on a timeline that has not been played yet.
  • The replay() function is called, regardless of the timeline state, since it replays the timeline from its beginning.

When a timeline has been set to repeat, the event handler runs at the beginning of the first repetition and does not run for each successive repetition. To set an event handler that runs when a timeline repeats, use the onRepeat() function.

If an event handler is already set for onStart, setting a new event handler overrides the one set previously.

To remove an event handler you set previously, call the onStart() function and pass null for the handler parameter.

Method Declaration
Method Parameters

The name of the function or the function expression to run when the timeline starts playing.

Was this helpful?