Skip to content

Instantly share code, notes, and snippets.

@wplit
Last active March 17, 2021 23:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wplit/c64420aacfaf336d544d6f8d62a48a47 to your computer and use it in GitHub Desktop.
Save wplit/c64420aacfaf336d544d6f8d62a48a47 to your computer and use it in GitHub Desktop.
add status to carousel builder (add to code block)
jQuery(document).ready(function($) {
let carouselSelector = '.my-carousel'; /* Change to your carousel class */
let statusSelector = '.oxy-carousel-builder_status'; /* Change to your text component class */
let $carousel = $(carouselSelector).find($(carouselSelector).children().data('carousel'));
var flkty = $carousel.data('flickity');
if (flkty) {
function updateStatus() {
var cellNumber = flkty.selectedIndex + 1;
$(statusSelector).text( cellNumber + '/' + flkty.slides.length );
}
updateStatus();
}
$carousel.on( 'change.flickity', updateStatus );
});
@amandalucas
Copy link

From David’s post:l on FB:

  1. Add a text component somewhere on the page for the status
  2. Give the text component a class, and your carousel a class.
  3. Use this code inside a code block..
  4. Customise to taste

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment