在 iPad(或移动仿真模式铬)。追踪时touchmove
body 上的事件并从 dom 中删除一个元素(touchstart 开始的元素)touchmove
来自身体的事件停止触发。
我做了一个example: http://jsbin.com/yinodosuxo/1/edit?js,控制台,输出
有什么办法可以让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
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)