Search.../

onCurrentItemChanged( )

Adds an event handler that runs when a gallery's current item changes.

Description

A gallery's current item changes through playing or certain user interactions.

Notes:

  • The onCurrentItemChanged() function is supported by galleries where the hasCurrentItem capability is true.

  • If you change the gallery's type to one that doesn't support hasCurrentItem and you try to use it, your code may no longer function correctly.

Syntax

function onCurrentItemChanged(handler: GalleryItemChangedEventHandler): Gallery
handler: function GalleryItemChangedEventHandler(event: GalleryItemChangedEvent): void

onCurrentItemChanged Parameters

NAME
TYPE
DESCRIPTION
handler

The name of the function or the function expression to run when the gallery's current item changes.

Returns

The gallery that triggered the event.

Return Type:

GalleryItemChangedEventHandler Parameters

NAME
TYPE
DESCRIPTION
event

The event that occurred.

Returns

This function does not return anything.

Return Type:

void

Was this helpful?

Get the information of the item that changed

Copy Code
1$w("#myGallery").onCurrentItemChanged( (event) => {
2 let itemDescription = event.item.description; // "Description"
3 let itemIndex = event.itemIndex; // 3
4} );