【问题标题】:Enable pinch to zoom in chrome app启用捏放大 chrome 应用程序
【发布时间】:2016-03-04 11:18:56
【问题描述】:

目前我正在开发一个包含谷歌地图的打包 Chrome 应用程序。但是,我无法使用捏合进行缩放。网页上的“正常”缩放也不起作用。

如果我直接在 Google Chrome 中打开它们,我使用的所有页面(和地图)都可以缩放,但我似乎无法在包应用程序中使用它们。有任何想法吗?这可能是权限问题还是 WindowOptions 问题?

在 Mac 10.11.3 上工作。 Chrome 版本 48.0.2564.116

简单示例(保管箱链接):zoomtest

manifest.json

{
    "name": "Zoom test",
    "version": "0.1",
    "manifest_version": 2,
    "app": {
        "background": {
            "scripts": ["background.js"]
        }
    }
}

background.js

chrome.app.runtime.onLaunched.addListener(function() {
    chrome.app.window.create('index.html', {
        innerBounds: { width: 800, height: 600 },
        state: 'normal'
    });
});

index.html

<html>
<head>
<style>
p {
    width: 400px;
}
</style>
</head>
<body>
<p>This page is zoomable in Google Chrome if opened directly,
but not if run as an app.</p>

</body>
</html>

【问题讨论】:

  • 向我们展示您是如何嵌入地图的。
  • 我也有非地图页面。当直接在 Chrome 中打开它们时,我可以用捏合放大 HTML 页面。但在 Chrome 应用程序中我不能。有没有我遗漏的设置?
  • 也许吧。尽管如此,还是举一个最小的例子。
  • link 我也会尝试把代码贴在这里
  • 好吧,不用运行,这只是not going to work。与缩放无关 - 它根本不起作用

标签: google-chrome google-chrome-app gestures pinchzoom


【解决方案1】:

我设法通过使用以下函数来修复它:

function mapTouchFix(){
  if("ontouchstart" in window || window.DocumentTouch && document instanceof DocumentTouch){
    navigator = navigator || {};
    if(navigator.platform!='MacIntel'){
      navigator.msMaxTouchPoints = navigator.msMaxTouchPoints || 2;
    }
  }
}

显然这欺骗了 Chrome / Google 地图以启用捏合手势

【讨论】:

    猜你喜欢
    • 2012-04-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-07-18
    • 2018-06-22
    • 1970-01-01
    • 2013-02-17
    相关资源
    最近更新 更多