启用捏合以放大Chrome应用

时间:2016-03-04 11:18:56

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

目前,我正在使用包含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>

1 个答案:

答案 0 :(得分: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地图可启用捏合手势

相关问题