Removing hammer events

后端 未结 2 1017
既然无缘
既然无缘 2021-01-05 20:57

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

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


        
2条回答
  •  清歌不尽
    2021-01-05 21:39

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

提交回复
热议问题