简体   繁体   English

Phonegap Android捏放大

[英]Phonegap Android Pinch Zoom

I am developing Android Application using jQuery Mobile and Phonegap. 我正在使用jQuery Mobile和Phonegap开发Android应用程序。 I want to enable pinch zoom on App pages. 我想在应用页面上启用缩放。 So many solutions suggested to use following line, but it isn't working - 建议使用以下方法的解决方案太多,但无法正常工作-

<meta id="viewport" name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=yes">

Is there any perfect solution for zooming App pages on pinch or on double click the page ? 是否有对捏 或双击页面缩放应用页面的任何完美的解决方案? Thanks. 谢谢。

i´ve been dealing this problem for years. 我多年来一直在解决这个问题。 In all this time i just found a kind of solution. 在这段时间里,我只是找到了一种解决方案。

You can create the image you want to zoom in two or more sizes. 您可以创建要放大两个或更多个尺寸的图像。 By the function show and hide found for Jquery at W3Schools(ShowHide) you can manage one to hide and the other one to show on tap above each one on display. 通过在W3Schools(ShowHide)中为Jquery找到的显示和隐藏功能,您可以管理一个隐藏并在另一个显示时轻按另一个显示。

It did work for me, although it does not enables zoom by pinch gesture it is an easy and robust way to show details from images using phonegap. 它确实对我有用,尽管它无法通过捏合手势进行缩放,这是一种使用Phonegap显示图像细节的简便而强大的方法。

Here is how i did it using only JS. 这是我仅使用JS的方法。

Introducing script on the header: 标头上的脚本介绍:

<script type="text/javascript">
function ampliar() {
        var e = document.getElementById("granderizable");
          if(e.style.display == 'block')
            e.style.display = 'none';
          else
            e.style.display = 'block';}
</script>

calling on images in the body: 调用人体中的图像:

<pec><a href="#" onClick="ampliar();"><img src="001.jpg" width="400" height="250" /></a></pec>
<gran id="granderizable" ><a href="#" onClick="ampliar();"><img src="001ZOOM.jpg" width="1280" height="800" /></a></gran>

Function ampliar looks for the Html element in the body whos id is granderizable and changes his style display value (Displayed or not displayed). 功能放大器在其id可识别的正文中查找Html元素,并更改其样式显示值(已显示或未显示)。

This function is activated when clicking on any of the images. 单击任何图像时将激活此功能。 When taping pec ,the small view image, its sets on diplay gran . 拍击佩奇(pec )的小视图图像时,它位于diplay gran上 This image, bigger, overlaps the small one. 此图像较大,与较小图像重叠。 Taping again on it would alternate its display value and banish it from the view of the app user allowing him to his prior view with the small image. 再次点按它会改变其显示值,并从应用程序用户的视角消除它,从而使他可以使用小图像查看以前的视图。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM