Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Based on this post on the community about creating an automatic slide show gallery on mobile, I am wondering how to make the autoplay function a selectable option. I tried to manipulate the code as follows, but haven't been able to make it work:
in gallery.liquid I added:
{% if section.settings.enable_carousel %} gallery--mobile-carousel slick-slider-overlay-dots data-autoplay="{{ section.settings.autoplay }}" data-autoplay-speed="{{ section.settings.autoplay_speed }}"{% endif %}
and in schema:
{
"id": "autoplay",
"type": "checkbox",
"label": "Auto-rotate slides",
"default": false
},
{
"type": "range",
"id": "autoplay_speed",
"min": 1,
"max": 20,
"step": 1,
"unit": "s",
"label": "Change slides every",
"default": 7
}
Then I added the following in theme.js:
$carouselGallery.on('init', function () {
$('.lazyload--manual', this).removeClass('lazyload--manual').addClass('lazyload');
}).slick({
autoplay: $(this).data('autoplay'),
fade: false,
speed: 600,
autoplaySpeed: autoplaySpeed,
infinite: true, ...
Which part am I missing?
https://semu1lktjsng69ep-60850798810.shopifypreview.com
Hi @lenarei,
Sorry for the delay, I checked and it works fine, did you solve it?
Hi @LitExtension,
Thanks for your answer. I got the gallery to auto-rotate on mobile, but now this is the only option, I cannot set it up so that the user will have to slide manually. I would like to be able to turn the auto-rotate on/off depending on where I use the section on my website.
This is what I added in gallery.liquid via schema and is visible on the front-end. But it doesn't change back to manual rotation when I uncheck the option here.
Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024