【问题标题】:How to prevent touchmove event move the background using jquery /javascript?如何防止 touchmove 事件使用 jquery / javascript 移动背景?
【发布时间】:2013-01-07 05:05:46
【问题描述】:

目前我正在为 ipad Safari 开发一个网站

我用过

addEventListener('touchmove', function(e) { e.preventDefault(); }, true);

在拖动内容时防止背景移动。问题是当我允许拖动某些元素时

    addEventListener('touchmove', function(e) { 
    //alert (e.target.id);
    if ( e.target.className != 'issues' && e.target.id != 'dialog' && e.target.id != 'issuesBox') 
    e.preventDefault(); 
    return false;
    }, true);

当我拖动元素时,它也会拖动背景,如何解决这个问题?我观察到这个问题可能是由 taphold 引起的,谢谢。

【问题讨论】:

    标签: javascript jquery ipad mobile touchmove


    【解决方案1】:

    您是否试图阻止在某些元素上滚动?然后防止 touchstarttouchmove 事件的默认值。这是来自苹果的doc

    根据我的经验,防止 touchstart 事件的默认值就足够了,例如,

    $(document).on('touchstart', function (evt) {
        evt.preventDefault();
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-31
      • 1970-01-01
      • 2017-02-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-17
      相关资源
      最近更新 更多