How to know which frame is selected in Carousel component?

224 views Asked by At

In Google Web Designer, I've added a carousel control. How can I know which image the user is currently viewing?

I added a new Frame Activated event, and created a custom action:

<script type="text/javascript" gwd-events="handlers">
    window.gwd = window.gwd || {};
    gwd.boardSelectionChanged = function(event) {
      // which frame is showing now?
    };
</script>

I need to know the current frame id.

1

There are 1 answers

0
San Khong On BEST ANSWER

You can get the current frame index using the following example:

var gallery = document.getElementById('gwd-carouselgallery_1');
console.log(gallery.currentIndex);

'gwd-carouselgallery_1' is the ID of the carousel.