Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stop hammer.js event propagation

Tags:

hammer.js

How to stop event propagation in Hammer.js (2.0.2)? The technique used in the relevant test (https://github.com/hammerjs/hammer.js/blob/master/tests/unit/test_propagation.js) does not apply to all type of events. If you replace the 'tap' event with a 'press' one, the test fails.

like image 474
nlyk Avatar asked Aug 27 '14 14:08

nlyk


1 Answers

In your parent element check what the event.target is. If it is not the parent element and is set to the child then ignore the event.

eg: if(event.target != parent){ return; }

like image 186
user2616676 Avatar answered Oct 21 '22 23:10

user2616676