Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

122
Vistas
Hammerjs is not detecting swipe movement

I'm using Hammerjs 2.0.8 with Nuxt, and I can't seem to make it detect swipe motion. Here's how I've done the setup. If I change the recognizer to [Hammer.Pan, { direction: Hammer.DIRECTION_HORIZONTAL }] and on pan event hammer.on('pan', this.handleTouchEvents); it runs this.handleTouchEvents method.

<template>
  <v-app>
    <v-main>
      <v-container id="touch-container" fluid>
        <div class="items">
          ...
        </div>
      </v-container>
    </v-main>
  </v-app>
</template>

<script>

export default {
  mounted () {
    const Hammer = require('hammerjs')
    const touchContainer = document.getElementById('touch-container')
    const hammer = new Hammer.Manager(touchContainer, {
      recognizers: [
        [Hammer.Swipe, { direction: Hammer.DIRECTION_HORIZONTAL }]
      ]
    })

    hammer.on('swipe', this.handleTouchEvents)
  },
  methods: {
    handleTouchEvents (e) {
      alert(e.type)
    }
  }
}
</script>

<style scoped>
#touch-container {
  height: 100%;
  min-width: 100%;
  overflow-x: hidden;
}

#items {
  touch-action: pan-y;
}
</style>

Any idea how to resolve this issue?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

touchContainer is probably undefined.

2 Things:

  1. Check if its on client side with process.client
  2. Wait until Vue created the elements on the UI with this.$nextTick()

Here try this:

  async mounted () {
 
    if(process.client) {
       await this.$nextTick();
       const Hammer = require('hammerjs')
       const touchContainer = document.getElementById('touch-container')
       const hammer = new Hammer.Manager(touchContainer, {
         recognizers: [
           [Hammer.Swipe, { direction: Hammer.DIRECTION_HORIZONTAL }]
         ]
       })

       hammer.on('swipe', this.handleTouchEvents)
    }
  },
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda