0

I need to create an interaction that lets the user swipe (right-left) among images on mobile. I'm using Jquery and I would like to stay with it. I know about jquery mobile, but if I can avoid it, it's better. If I have no option, I would use it anyway.

I tried many things and looked for answers, but nothing seems to fulfill my needs.

My ambition is to have the website do something when I swipe right or left. Something similiar to what I achieve with the 'mousewheel' event, but on mobile a with right-left swipe (instead of the mousewheel).

I will really appreciate any suggestion

loop123123
  • 21
  • 1
  • 6

2 Answers2

0

Looks like Hammer.js is what you are looking for. It also include a jQuery plugin

Not using any dependencies, you can listen to events touchstart, touchmove, touchend, touchcancel: How to recognize touch events using jQuery in Safari for iPad? Is it possible?

sebastienbarbier
  • 6,542
  • 3
  • 29
  • 55
  • Can't I just do it with vanilla Javascript or Jquery? I thought I was easier.... I'm working on someones project and I don't think that installing Hammer is best option. Still, thanks, if there is no alternative, I'll consider that one. – loop123123 Jul 26 '19 at 13:02
  • You will need to listen manually all events, not the best I would avoid and add 7kb of dependancies for such things. There is options, I'll update my answer. – sebastienbarbier Jul 26 '19 at 13:29
0

Basic jQuery doesn't provide swipe options, you can either use jQuery mobile or ionic (you can include just the js part). I have used both for my hybrid apps but I felt ionic is better in performance and easy to implement.

Tapas
  • 1,123
  • 8
  • 16