我正在使用Phonegap,我想使用jquery mobile在pinch上使用放大/缩小选项。 我已经尝试过jgesture和锤子插件进行缩放。我在这段代码中错在哪里?
<html>
<head>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 -->
<meta name="viewport" content="user-scalable=yes, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<link rel="stylesheet" type="text/css" href="css/index.css" />
<link rel="stylesheet" type="text/css" href="css/jquery.mobile-1.4.1.min.css" />
<title>Hello World</title>
<script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
<script>
$(document).bind("mobileinit", function(){
$.mobile.metaViewportContent = "width=device-width, minimum-scale=1, maximum-scale=2";
});
</script>
<script type="text/javascript" src="js/jquery.mobile-1.4.1.min.js"></script>
</head>
<body>
<div class="app">
<h1>PhoneGap</h1>
<div id="deviceready" class="blink">
<p class="event listening">Connecting to Device</p>
<p class="event received">Device is Ready</p>
</div>
</div>
<script type="text/javascript" src="phonegap.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<script type="text/javascript">
app.initialize();
</script>
</body>
</html>
答案 0 :(得分:1)
使用hammer.js捏,pinchin,pinchout
以下是github上API的事件文档:
https://github.com/EightMedia/hammer.js/wiki/Getting-Started
另外,你基本上使它不是用户可扩展的......:
initial-scale=1, maximum-scale=1, minimum-scale=1,
这一行:
<meta name="viewport" content="user-scalable=yes, initial-scale=1, maximum-scale=1,
minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi"/>
然后使用jquery再次设置它:
$.mobile.metaViewportContent = "width=device-width, minimum-scale=1, maximum-scale=2";
不好,请在此处阅读: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta