谷歌浏览器捏合缩放预防 [英] Google Chrome Pinch-to-zoom prevention

查看:278
本文介绍了谷歌浏览器捏合缩放预防的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发运行Windows 8.1的Microsoft Surface Pro 2上的Chrome应用程序。最近,Chromium团队决定在Chrome 8 for Windows中添加捏缩缩手势,这一切都很好。然而,他们并没有在Chrome的设置中添加一个标志来禁止这种行为,以防止那些不想捏合缩放功能的我们这些少数人。

现在,我仍然试图通过其他方式禁用浏览器的默认行为。我试过的第一件事就是添加这个元标记:

 < meta name =viewportcontent =width = device-width,initial-scale = 1.5,maximum-scale = 1.5,user-scalable = no/> 

没有效果。我也一直在尝试使用hammer.js触摸库来禁用有限成功的行为;捏足够快,足够快,仍然放大页面。



有谁知道一个有效的方法来禁用Chrome的Windows 8.1的捏缩缩行为?

解决方案

基于用户的方法:



p>


  1. 转至 chrome:// flags

  2. 点击启用启用视口元标记



程序化方法



(如上面的评论中所建议的):
$ b $ ol

  • 收听 touchmove
  • 调用 preventDefault

    注意:始终防止 touchmove 会导致简单的滚动停止工作


    I'm developing an app for Chrome on a Microsoft Surface Pro 2 running Windows 8.1. Recently, the Chromium team decided they wanted to add the pinch-to-zoom gesture in Chrome for Windows 8, which is all and good. They did not, however, add a flag to disable this behavior in Chrome's settings for those few of us that don't want pinch-to-zoom functionality.

    Now I'm left trying to disable the browser's default behavior by other means. The first thing I tried was to add this meta-tag:

    <meta name="viewport" content="width=device-width, initial-scale=1.5, maximum-scale=1.5, user-scalable=no" />
    

    It had no effect. I've also been trying to use the hammer.js touch library to disable the behavior with limited success; pinching sufficiently fast enough still zooms the page.

    Does anyone know of a effective way to disable the pinch-to-zoom behavior on Chrome for Windows 8.1?

    解决方案

    User-based approach:

    Enable viewport meta tag support by:

    1. going to chrome://flags
    2. click enable "Enable viewport meta tag"

    Programmatic approach

    (as suggested in comments above):

    1. Listen to touchmove events
    2. call preventDefault on them if you detect two touches.

    Note: Always preventing touchmove would cause simple scroll to stop working

    这篇关于谷歌浏览器捏合缩放预防的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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