How to change the press gesture duration?


#1

Hi,

I have a button like this:

<button ion-button (press)="noteOptions(note)" (click)="openNote(note)"> {{note.title}} </button>

The press-event works, but I find the duration too short.
There is even an edge-case where both press and click events are fired.

Can I change the duration needed to fire the press event in Ionic 3?

Thanks


#2

Hi,
I had the same problem - needing to change the duration of the press event. This can be done by modifying HammerGestureConfig.

in app.module.ts add

import { HammerGestureConfig, HAMMER_GESTURE_CONFIG } from '@angular/platform-browser';

export class CustomHammerConfig extends HammerGestureConfig {
    overrides = {
        'press': { time: 1000 }  //set press delay for 1 second
    }
}

@NgModule({
...
  providers: [
    ...
     { provide: HAMMER_GESTURE_CONFIG, useClass: CustomHammerConfig }
  ]
})

#3

I tried to implement this in ionic 4 but receive the following error:

Uncaught Error: No NgModule metadata found for 'AppModule'.