Last active
March 17, 2021 23:27
-
-
Save wplit/c64420aacfaf336d544d6f8d62a48a47 to your computer and use it in GitHub Desktop.
add status to carousel builder (add to code block)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
From David’s post:l on FB: