Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing hammer events

I create an event using hammer.js library like this:

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

How can I then remove the registred event? Can I also use Jquery?

like image 251
Jacob Avatar asked Mar 15 '13 08:03

Jacob


1 Answers

It's simply Hammer(myElement).off(eventName);

If you want to use jQuery, then the syntax is:

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

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

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

which makes it possible to detach only desired event, eg:

$(myElement).hammer().off("tap.anotherNamespace");
like image 72
Samuli Hakoniemi Avatar answered Nov 20 '22 07:11

Samuli Hakoniemi