[solved] Ionic 4 (press|tap) events


#1

while trying to upgrade from ionic 3.9 to ionic 4-beta i encountered an inconsistency what is not documented in the Breaking changes.

in ionic 3 the event would propagate after a while if the button was long pressed

<button ion-button (press)="doSomething()">long press"</button>

but in ionic 4 no event is fired

<ion-button (press)="doSomething()">long press"</ion-button>

am i mission something?


Ionic4 Gestures - GestureController
#2

i solved it by adding hammerjs to main.ts file

npm install hammerjs

in src/main.ts


import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

import { AppModule } from './app/app.module';
import { environment } from './environments/environment';

/**
 * Hammerjs must be imported for gestures
 */
import 'hammerjs';

if (environment.production) {
  enableProdMode();
}

platformBrowserDynamic().bootstrapModule(AppModule)
  .catch(err => console.log(err));


#3

Thanks for this.
I have found it does not work on devices when using using Ionic DevApp but works fine after a build.