Proper way to set off() in jquery hammer events -
i'm wondering best way setting hammer.js configuration on simple document i'm working on. here's code:
var tappablearea = $('.content'); var touchablearea = $('.sidebar'); function reloadhammergestures() { tappablearea.hammer().off("doubletap"); touchablearea.hammer().off("swipeleft swiperight"); hammergestures(); } function hammergestures() { tappablearea.hammer().off("doubletap"); touchablearea.hammer().off("swipeleft swiperight"); if (fullscreenmode()) { touchablearea.hammer().on("swipeleft swiperight", function(event) { alert("swiped!"); }); else if (!fullscreenmode()) { tappablearea.hammer().on("doubletap", function(event) { alert("tapped"); }); } } $(document).ready(function() { hammergestures(); }); $(window).resize(function () { reloadhammergesture();; }); and function both loaded on $(document).ready() , (window).resize(), that's why i'm making .off() in beginning.. i'm wondering wrong method on getting disabled when screen-mode conditional changes, if can me in improving code, i'll happy.
take care , have nice day:)
well can this:
touchablearea.hammer().off().on(...) or $(touchablearea).unbind() work.
or both:
$('#touchablediv, #tappablediv').unbind() also: see on github added hammer.destroy() method.
also, see: removing hammer events
Comments
Post a Comment