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 thehasCurrentItem
capability istrue
.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): Galleryhandler: 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.
GalleryItemChangedEventHandler Parameters
NAME
TYPE
DESCRIPTION
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; // 34} );