25

I'm using Vue 2.0 and I should work with swipe gestures. I have checked that there is one official plugin (named vue-touch) but as they say, Vue 2.0 is not supported yet.

Which libraries are available for Vue 2.0 to implement touch events?

Asqan
  • 4,319
  • 11
  • 61
  • 100
  • I don't have a clear-cut answer for you by maybe using this in combination with vue could help you? http://hammerjs.github.io/ You could probably write your own directives for it making it a lot easier to use with Vue. – Stephan-v Mar 09 '17 at 15:09
  • I couldn't think a way to use directives for this purpose. the events of [directives](https://vuejs.org/v2/guide/custom-directive.html) are limited and i think we can't catch the event in directive itself. If it is possible, i would be happy to see this. – Asqan Mar 09 '17 at 15:40
  • there is already a vue2 branch -> [vue2-touch-events](https://www.npmjs.com/package/vue2-touch-events) – Mr.P Mar 24 '21 at 05:03

2 Answers2

12

I checked and there already is a vue-touch for Vue 2.0, it is on another branch though:

This branch is only compatible with Vue 1.0. For the Vue 2.0 compatible rewrite, see the next branch

https://github.com/vuejs/vue-touch/tree/next

Stephan-v
  • 19,255
  • 31
  • 115
  • 201
  • Is there another project may be? It seems that they are not working anymore on github. – Asqan Apr 13 '18 at 01:45
  • important note: Vue-touch has still serious issues in iOS that caused us to use something else. – Asqan Sep 10 '18 at 05:36
  • `vue2-touch-events`made an important release 9 days ago and it is currently the most popular package to manage touch events in Vue: https://www.npmjs.com/package/vue2-touch-events – Asqan Apr 04 '19 at 15:22
8

You can easily use Hammer directly in Vue. Create Vue directives to wrap the Hammer touch events you're interested in. Do this once for your whole app. This is easy and shouldn't put you off.

Vue2-hammer (1600 weekly npm downloads) also wraps hammer but for the moment I'm choosing to do this directly. Vue2-touch-events (5000 weekly npm downloads) does not leverage Hammer, which seems brave.

bbsimonbb
  • 27,056
  • 15
  • 80
  • 110
  • 2
    hammer.js unfortunately seems to have gone pretty stagnant. According to this thread (https://github.com/hammerjs/hammer.js/issues/1197) it looks like it's future is still being decided. – Jason Jun 10 '19 at 19:53