防止在iPad Safari中的网页之间滑动 [英] Prevent swiping between web pages in iPad Safari

查看:325
本文介绍了防止在iPad Safari中的网页之间滑动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从iPad的Safari浏览器的左右边缘轻扫,在当前打开的网页之间移动。有没有办法阻止它?

Swiping from the left and right edges of my iPad's Safari browser, moves between the currently open web pages. Is there any way to prevent it?

我试图添加 touchstart touchmove 页面边缘的处理程序 stopPropagation preventDefault ,但它们似乎有没有效果,也没有触摸动作 CSS。

I have tried to add touchstart and touchmove handlers on the edge of the page that stopPropagation and preventDefault, but they seem to have no effect, nor does touch-action CSS.

2014年有一个类似的问题回答了否定:
iOS 7 - 有没有办法在Safari中禁用滑动后退和前进功能?

A similar question was asked in 2014 with replies to the negative: iOS 7 - is there a way to disable the swipe back and forward functionality in Safari?

2018年是否有工作区?

Is there a workround now in 2018?

推荐答案

Apple在iOS9之后提供了这些指南。

Apple provided these guidelines after iOS9.

该指南让我们你禁用


  1. 滚动

  1. Scrolling

function touchMove(event) {
  // Prevent scrolling on this element
  event.preventDefault();
  ...
}


  • 捏合和缩放

  • Pinch and Zoom

    function gestureChange(event) {
      // Disable browser zoom
      event.preventDefault();
      ...
    }
    


  • 您可以按如下方式识别滑动手势:

    You can identify a swipe gesture as follows:


    1. 如果您收到包含一个
      目标触摸的touchstart事件,请开始手势。

    2. 如果您在任何时间收到超过1次触摸的事件
      ,则中止手势。

    3. 如果您收到的触摸移动事件
      主要是在x方向上,请继续手势。

    4. 如果您收到的触摸移动
      事件主要是y方向,则中止手势。

    5. 如果您收到touchend
      活动,请结束手势。

    1. Begin gesture if you receive a touchstart event containing one target touch.
    2. Abort gesture if, at any time, you receive an event with >1 touches.
    3. Continue gesture if you receive a touchmove event mostly in the x-direction.
    4. Abort gesture if you receive a touchmove event mostly the y-direction.
    5. End gesture if you receive a touchend event.

    完整指南是海报此处

    如果您需要更多帮助,请告诉我。

    Let me know if you need more help.

    Nitin,
    Defuzed

    这篇关于防止在iPad Safari中的网页之间滑动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆