Search.../

onPlay( )

Adds an event handler that runs when playback is started or restarted.

Description

An element can be played by a user clicking the gallery or slideshow's play button or by calling its play() function.

Notes:

Syntax

function onPlay(handler: EventHandler): Gallery | Slideshow
handler: function EventHandler(event: Event): void

onPlay Parameters

NAME
TYPE
DESCRIPTION
handler

The name of the function or the function expression to run when the element is played.

Returns

The gallery or slideshow that triggered the event.

Return Type:

EventHandler Parameters

NAME
TYPE
DESCRIPTION
event

The event that occurred.

Returns

This function does not return anything.

Return Type:

void
Mixed in from:$w.PlayableMixin

Related Content:

Was this helpful?

Get the ID of the element that is playing

Copy Code
1$w("#myElement").onPlay( (event) => {
2 let targetId = event.target.id; // "myElement"
3});