hammerjs / hammer.js

A javascript library for multi-touch gestures :// You can touch this
http://hammerjs.github.io
MIT License
24.1k stars 2.63k forks source link

tap does not fire after DOM modification (js) on iOS #984

Open mrbbp opened 8 years ago

mrbbp commented 8 years ago

i try to code an ios "spring board" behavior: LONG PRESS on an icon make it jiggle, TAP on icon remove it, TAP on background stop jiggle mode. It works fine on desktop (safari + chrome osx) but does not on ios (only) after removing an icon (dom removeChild). the TAP on background does not fire any more. (but fire if i do not mod the DOM)

code here test here

any idea?

i use the propagating.js lib to avoid propagation on parent.

mrbbp commented 8 years ago

occur too when modifying the display (display:'none') of the taped icon. the tap background does not fire.

mrbbp commented 8 years ago

Well i've found a trick with the "hammer.input" (secret weapon) who is fire well, but it's strange behavior hammerBody.on("hammer.input", function(ev) { //console.log("hammerbody secret:",ev.pointers); if (ev.pointers[0].target.id == 'groupe' && delMode) { for (var i = 0; i < el.length; i++) { el[i].classList.remove('gigote'); el[i].querySelector('.eff').classList.remove('visible'); } delMode = false; } });

the trick block the TAP event on Desktop browsers... I've made an huggly stuff by detecting userAgent and use hammer.input for ios/android and tap detection for desktop...

mrbbp commented 8 years ago

working code here

wakatanka commented 8 years ago

Hi mrbbp, i've the same problem, i'have to pinch a div after it's contents was replaced (by jquery) but i don't understand your code, can you give me some hints?

thanks

mrbbp commented 8 years ago

I've used this: http://hammerjs.github.io/api/#hammer.input-event You have access to a lot of info about what trigger and you can find the right object