javascript - Touchmove event stops triggering after any element is removed from dom -
on touch devices such ipad (or mobile emulaton mode in chrome). when tracking touchmove
event on body , removing element (on touchstart started) dom touchmove
events body stops triggering.
i made example: http://jsbin.com/yinodosuxo/1/edit?js,console,output
is there way touchmove
continue working after child element removed?
i fixed issue caching element until touchend
event emitted. pseudo code view triggered touchstart
event this:
view.remove = function () { if (didviewstarttouchevents) { var _this = this; this.hideelement(); // display: none, opacity: 0, etc elementcache.appendchild(this); //append element other place body. not needed might handy depending on situation document.body.addeventlistener('touchend', function () { _this.didviewstarttouchevents = false; _this.remove(); }); } else { // regular remove & cleanup } }
Comments
Post a Comment