onComplete( )


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

The event handler set by calling the onComplete() function runs when a timeline completes playing by reaching the end.

When a timeline has been set to repeat, the event handler runs at the end of the last repetition and does not run for the preceding repetitions.

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

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

Method Declaration
Copy
function onComplete(handler: Function): TimeLine;
Method Parameters
handlerFunctionRequired

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

Returns
Return Type:TimeLine
JavaScript
import wixAnimationsFrontend from "wix-animations-frontend"; let timeline = wixAnimationsFrontend.timeline(); // ... timeline.onComplete(() => { // handle timeline forwards completion console.log("Timeline has completed playing in reverse."); });
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?