1

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.

Johannes
  • 64,305
  • 18
  • 73
  • 130
Blendester
  • 1,583
  • 4
  • 19
  • 43
  • Hey OP, in order to give some really specific code examples it would be helpful to see the markup of the GWD generated carousel. I think yu can preview your page, and then if you right-click the carousel and 'view source' you can copy and paste the html in your OP – DMcCallum83 Sep 18 '17 at 15:59

1 Answers1

2

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.

moggi
  • 1,466
  • 4
  • 18
  • 29
San Khong
  • 36
  • 1