Skip to content

Instantly share code, notes, and snippets.

@wplit
Created February 24, 2021 22:39
Show Gist options
  • Select an option

  • Save wplit/6599bf0dc0c3ebce827721ab4b4808ba to your computer and use it in GitHub Desktop.

Select an option

Save wplit/6599bf0dc0c3ebce827721ab4b4808ba to your computer and use it in GitHub Desktop.
force carousel autoplay to stop on last cell
jQuery(document).ready(function($) {
let $carousel = $('#%%ELEMENT_ID%%').find($('#%%ELEMENT_ID%%').children().data('carousel'));
let numberCells = $('#%%ELEMENT_ID%%').find($('#%%ELEMENT_ID%%').children().data('cell')).length;
$carousel.on( 'settle.flickity', function( event, index ) {
if ((index + 1) == numberCells) {
$carousel.flickity('pausePlayer');
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment