• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

javascript - 说明您可能使用触摸 Action 的情况 : manipulation

[复制链接]
菜鸟教程小白 发表于 2022-12-13 13:56:43 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

见过

touch-action: manipulation;

在各种网站的CSS中应用于按钮和链接。我很好奇这样做的目的是什么?

我阅读了 Mozilla Developer Network 上的值

The touch-action CSS property specifies whether, and in what ways, a given region can be manipulated by the user (for instance, by panning or zooming).

auto: The user agent may determine any permitted touch behaviors, such as panning and zooming manipulations of the viewport, for touches that begin on the element.

none: Use this value to disable all of the default behaviors and allow your content to handle all touch input (touches that begin on the element must not trigger default touch behaviors).

pan-x: The user agent may consider touches that begin on the element only for the purposes of horizontally scrolling the element's nearest ancestor with horizontally scrollable content.

pan-y: The user agent may consider touches that begin on the element only for the purposes of vertically scrolling the element's nearest ancestor with vertically scrollable content.

manipulation: The user agent may consider touches that begin on the element only for the purposes of scrolling and continuous zooming. Any additional behaviors supported by auto are out of scope for this specification.

但我不明白将其应用于大多数链接/按钮背后的想法。这是否可以防止使用默认值 auto 通常会出现的常见问题?



Best Answer-推荐答案


根据站点 post , touch-action: handling 有助于防止 PointerEvents通过消除每个事件检测延迟来触发。例如,双击屏幕时可能会触发双击事件,直到 300 毫秒的情况下 touch-action: handling 未被声明。

短引号:

Most touch-based mobile browsers wait 300ms between your tap on the screen and the browser firing the appropriate handler for that event. It was implemented because you could be double-tapping to zoom the page to full width. Therefore, the browser waits for a third of a second — if you don’t tap again, the “click” is activated.

...

Microsoft has solved many touch-based issues in the PointerEvents specification. For example, the pointerup event won’t be fired if the user is scrolling the page.

There is also a non-standard CSS touch-action property which allows you to remove the delay on specific elements or the whole document without disabling pinch-zooming:

a, button, .myelements { ... }

我不确定情况,这取决于您是否对屏幕点击不满意,所以比较是个好主意。

关于javascript - 说明您可能使用触摸 Action 的情况 : manipulation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38958354/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap