Removing milk events

I create an event using the hammer.js library as follows:

Hammer(myElement).on("doubletap", function(evt){ evt.preventDefault(); }); 

How can I delete a registered event? Can I use jQuery?

+4
source share
1 answer

This is just Hammer(myElement).off(eventName);

If you want to use jQuery, the syntax is as follows:

 $(myElement).hammer().on(eventName, callback) 

If you want to specify a "namespace" for the event, then you declare, for example.

 $(myElement).hammer().on("tap.namespace", callback); $(myElement).hammer().on("tap.anotherNamespace", callback2); 

which allows you to separate only the desired event, for example:

 $(myElement).hammer().off("tap.anotherNamespace"); 
+11
source

Source: https://habr.com/ru/post/1469438/


All Articles