[英]Touchmove event stops triggering after any element is removed from dom
在触摸设备上,如iPad(或铬合金的移动仿真模式 )。 当跟踪touchmove
上的touchmove
事件并从dom touchmove
事件中删除一个元素(在touchstart上启动)时,从身体停止触发。
我做了一个例子 : http : //jsbin.com/yinodosuxo/1/edit?js,console,output
即使删除了子元素, touchmove
还有什么方法可以继续工作吗?
我通过缓存元素来修复此问题,直到发出touchend
事件。 触发touchstart
事件的视图的伪代码如下所示:
view.remove = function () {
if (didViewStartTouchEvents) {
var _this = this;
this.hideElement(); // display: none, opacity: 0, etc
elementCache.appendChild(this); //append this element to some other place like body. Not needed but might be handy depending on situation
document.body.addEventListener('touchend', function () {
_this.didViewStartTouchEvents = false;
_this.remove();
});
} else {
// regular remove & cleanup
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.