Created
February 28, 2021 04:37
-
-
Save wplit/ff8e9c9c124f84c23c46749282bdcc2d to your computer and use it in GitHub Desktop.
Add class to carousel builder if not enough cells. Add to carousel builder > advanced > javascript
This file contains hidden or 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 minimumCells = 2; /* Change to minimal cells needed for navigation */ | |
| let $carousel = $('#%%ELEMENT_ID%%').find($('#%%ELEMENT_ID%%').children().data('carousel')); | |
| let numberCells = $('#%%ELEMENT_ID%%').find($('#%%ELEMENT_ID%%').children().data('cell')).length; | |
| $carousel.on( 'ready.flickity', function() { | |
| if (minimumCells > numberCells) { | |
| $('#%%ELEMENT_ID%%').addClass('hide-carousel-nav'); | |
| } | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment