[solved] Ionic 4 (press|tap) events

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?

1 Like

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));

5 Likes

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

Thank’s:grinning:jhkjlhlkjhkjh

This may be off topic, but what is the difference of using the press event vs the click event?

Don’t know if it still applies to ionic 4 but in ionic 3 the (click) event would sometimes cause a lag event event firing if used on a mobile device compared to (tap) event; causing slight UI lag, so I always used (tap)

as in (tap)=myFunc() ? … (tap) doesn’t work for me … or you mean that (press) == (tap) ?
Actually neither works … only (click):confused:

I am also trying this but i can’t achieve triple click.
i am using this

what will do please help to solve this