Step-by-step to implement tap-to-next in your slideshow section:
- Locate the Slideshow Section Code
In your Shopify admin, go to Online Store > Themes.
Click Actions > Edit code.
Find the file for your slideshow, usually something like:
sections/slideshow.liquid or sections/main-slider.liquid.
- Add a Tap Overlay & Script
You need to:
Add an invisible clickable layer over the image.
Use JavaScript to trigger the next slide when tapped.
Modify your slideshow HTML like this:
{% for slide in section.settings.slides %}
{% endfor %}
Add this CSS to your theme’s stylesheet (e.g., assets/base.css):
.tap-overlay {
position: absolute;
top: 0; left: 0;
width: 100%;
height: 100%;
z-index: 5;
}
.slideshow-container {
position: relative;
}
Then, add this JS snippet to assets/theme.js or directly in the section using tags:
document.addEventListener(“DOMContentLoaded”, function() {
const overlay = document.querySelector(“.tap-overlay”);
const slides = document.querySelectorAll(“#custom-slideshow .slide”);
let currentSlide = 0;
function showSlide(index) {
slides.forEach((slide, i) => {
slide.style.display = i === index ? “block” : “none”;
});
}
overlay.addEventListener(“click”, function() {
currentSlide = (currentSlide + 1) % slides.length;
showSlide(currentSlide);
});
showSlide(currentSlide); // Show the first slide initially