Sets an event handler that runs when a the timeline repeats.
The event handler set by calling the onRepeat()
function runs when a
timeline begins playing a repetition. It does not run for the initial
play of the timeline. However, when replaying a timeline that has already
been played, the event handler runs even for the first repetition of
the timeline.
If an event handler is already set for onRepeat
, setting a new event
handler overrides the one set previously.
To remove an event handler you set previously, call the onRepeat()
function and pass null
for the handler
parameter.
function onRepeat(handler: Function): TimeLine;
The name of the function or the function expression to run when the timeline repeats.
import wixAnimationsFrontend from "wix-animations-frontend";
let timeline = wixAnimationsFrontend.timeline({ repeat: 3 });
// ...
timeline.onRepeat(() => {
// handle timeline repetition
console.log("Timeline is repeating.");
});
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.