Rob*_*Fox 5 html javascript mobile-safari touch
在 iPad 等触控设备上(或chrome 中的移动仿真模式)。当跟踪touchmovebody 上的touchmove事件并从 body 的dom事件中移除一个元素(在该元素上启动 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
  }
}
| 归档时间: | 
 | 
| 查看次数: | 1153 次 | 
| 最近记录: |