Touch Events in Vue 2.0 [closed]
Asked Answered
C

2

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?

Considering answered 9/3, 2017 at 11:16 Comment(3)
I don't have a clear-cut answer for you by maybe using this in combination with vue could help you? hammerjs.github.io You could probably write your own directives for it making it a lot easier to use with Vue.Univalent
I couldn't think a way to use directives for this purpose. the events of directives 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.Considering
there is already a vue2 branch -> vue2-touch-eventsMalapropism
U
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

Univalent answered 9/3, 2017 at 15:59 Comment(3)
Is there another project may be? It seems that they are not working anymore on github.Considering
important note: Vue-touch has still serious issues in iOS that caused us to use something else.Considering
vue2-touch-eventsmade an important release 9 days ago and it is currently the most popular package to manage touch events in Vue: npmjs.com/package/vue2-touch-eventsConsidering
B
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.

Bravo answered 28/1, 2019 at 15:12 Comment(1)
hammer.js unfortunately seems to have gone pretty stagnant. According to this thread (github.com/hammerjs/hammer.js/issues/1197) it looks like it's future is still being decided.Creamy

© 2022 - 2024 — McMap. All rights reserved.