Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular: when update from 8 to 9 - hammerjs + @angular/platform-browser stopped working

I'm using hammerjs for detecting swipe on a small Angular 8 app.

I followed this article - https://medium.com/angular-in-depth/gestures-in-an-angular-application-dde71804c0d0 - and I'm using hammerjs with @angular/platform-browser.

However, when 3 days ago Angular 9 was released - I updated with no issues, but now swiping detection is not working at all :( ... don't see errors or warnings. Also - didn't see any notes for platform-browser changes in the update release notes.

Any ideas what's wrong and how to fix it?

like image 603
pesho hristov Avatar asked Feb 09 '20 16:02

pesho hristov


People also ask

How do you use Hammerjs in angular 9?

The most important thing is to import the HammerModule in app module file. In your angular project, install the hammerjs package locally by running the below command. Now, you will need to import the hammerjs module in your main. ts file.


1 Answers

I had the same issue and managed to come across this article which has solved my problem.

hammerjs is now optional
In earlier versions hammerjs was required to add gesture support, it is optional now and all implementation used internally is removed, you can use HammerModule from @angular/platform-browser.

Simply adding the HammerModule import to my AppModule fixed it.

like image 175
Stefan Charsley Avatar answered Oct 19 '22 18:10

Stefan Charsley