How to add swipe gesture to slideshow

Solved

How to add swipe gesture to slideshow

CreatorTim
Navigator
471 1 71

Heey, how can I add a feature to my slideshow section so that when someone swipes left/right on mobile, it switches to the next image?

 

Like when you're swiping through Instagram stories — I want the same kind of swipe gesture to switch to the next slide.

 

Here’s my store: https://creationwithtim.com/products/cinematiq-lut-collection-copy
(Just scroll all the way down to find the slideshow section)

 

Thanks a lot,
Tim

Accepted Solution (1)

Small_Task_Help
Shopify Partner
1054 45 102

This is an accepted solution.

Hi,

Hope this will help

- Add Hammer.js to Your Theme
- Find Your Slideshow Section Code
- Add an ID to Your Slideshow Container
- Add Swipe Script and include it in theme
Script example

document.addEventListener("DOMContentLoaded", function () {
  var slideshow = document.getElementById('mobile-swipe-slideshow');
  
  if (!slideshow) return;

  var hammer = new Hammer(slideshow);

  hammer.on("swipeleft", function () {
    document.querySelector('.slideshow__button--next').click();
  });

  hammer.on("swiperight", function () {
    document.querySelector('.slideshow__button--prev').click();
  });
});
To Get Shopify Experts Help, Click Here or E-mail - hi@ecommercesmalltask.com
About Us - We are Shopify Expert India
At Google My Business - Ecommerce Small Task - Hire Shopify Developers Ahmedabad

View solution in original post

Reply 1 (1)

Small_Task_Help
Shopify Partner
1054 45 102

This is an accepted solution.

Hi,

Hope this will help

- Add Hammer.js to Your Theme
- Find Your Slideshow Section Code
- Add an ID to Your Slideshow Container
- Add Swipe Script and include it in theme
Script example

document.addEventListener("DOMContentLoaded", function () {
  var slideshow = document.getElementById('mobile-swipe-slideshow');
  
  if (!slideshow) return;

  var hammer = new Hammer(slideshow);

  hammer.on("swipeleft", function () {
    document.querySelector('.slideshow__button--next').click();
  });

  hammer.on("swiperight", function () {
    document.querySelector('.slideshow__button--prev').click();
  });
});
To Get Shopify Experts Help, Click Here or E-mail - hi@ecommercesmalltask.com
About Us - We are Shopify Expert India
At Google My Business - Ecommerce Small Task - Hire Shopify Developers Ahmedabad