Search...
onRepeat( )
Sets an event handler that runs when a the timeline repeats.
Description
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.
Authorization
Request
This endpoint does not take any parameters
Response Object
The timeline the event handler was set on.
Returns an empty object.
Status/Error Codes
Was this helpful?
Set an event handler that runs when a timeline repeats
Copy Code
1import wixAnimationsFrontend from 'wix-animations-frontend';23let timeline = wixAnimationsFrontend.timeline({"repeat": 3});45// ...67timeline.onRepeat( () => {8 // handle timeline repetition9 console.log("Timeline is repeating.");10} );
Remove the event handler that runs when a timeline repeats
Copy Code
1import wixAnimationsFrontend from 'wix-animations-frontend';23let timeline = wixAnimationsFrontend.timeline();45// ...67timeline.onRepeat( null );
Display a message when a timeline repeats
Copy Code
1import wixAnimationsFrontend from 'wix-animations-frontend';23let timeline = wixAnimationsFrontend.timeline({"repeat": 3});45$w.onReady( function () {6 const myImage = $w("#myImage");78 timeline9 .add( myImage, {10 "rotate": 360,11 "scale": .5,12 "duration": 100013 } )14 .add( myImage, {15 "opacity": 0,16 "duration": 100017 } )18 .onRepeat( () => {19 $w("#messageText").text = "Timeline is repeating.";20 } )21 .play();22} );