Removing hammer events

后端 未结 2 1016
既然无缘
既然无缘 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:28

    In the documentation of hammer.js API, it is stated that it will not remove the dom events, using $(element).off() will not resolve your issues, a work around is to use the hammer.js jquery wrapper, their events are registered on an element using the bind function. Use the unbind to remove all or specific events.

    $(element).hammer().unbind();

    $(element).hammer().bind('swipeleft', 'swiperight', function(){});

    The wrapper is here: https://github.com/hammerjs/jquery.hammer.js/blob/master/jquery.hammer.js

提交回复
热议问题