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
App won't recognize swipes using Hammer.JS and HammerGestureConfig in Angular 9

I can't recognize swipes in my Angular app using Hammer.JS. It's setup like this:

"@angular/core": "~9.0.0-next.6",
"hammerjs": "^2.0.8",
"zone.js": "~0.10.2"

app.module.ts is looking like this:

import { BrowserModule, HammerGestureConfig, HAMMER_GESTURE_CONFIG } from '@angular/platform-browser';
import * as hammer from 'hammerjs';

export class MyHammerConfig extends HammerGestureConfig {
  overrides = <any>{
    swipe: { direction: hammer.DIRECTION_HORIZONTAL },
    pinch: { enable: false },
    rotate: { enable: false }
  };
}

@NgModule({
  imports: [
    BrowserModule,
  ],
  providers: [
    {
      provide: HAMMER_GESTURE_CONFIG,
      useClass: MyHammerConfig
    }
  ],
})

app.component.ts has this method:

onSwipe() {
  console.log('swipe');
}

And finaly app.component.html looks like this:

<div (swipeleft)="onSwipe()" (swiperight)="onSwipe()">
  <h1>Swipe here</h1>
</div>

However, neither swipeleft or swiperight are triggered ever using an iPad or iPhone both running iOS 13.

Am I missing any crucial configuration? Or do I have another issue with this code?


I also tested this Stackblitz "blog-ng-swiping" which is working fine on the touch devices, but it's using Angular 8.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

It turns out that Angular 9 has a new HammerModule which is used for everything Hammer.JS related and also for tree shaking during compilation.

So besides the whole configuratonion of Hammer.JS, gestures etc. you need to include this Module in your app as well to make Hammer.JS work with Angular 9:

import { HammerModule } from '@angular/platform-browser';

@NgModule({
  imports: [
    HammerModule
  ]
)}
over 4 years ago · Santiago Trujillo 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