JQuery Mobile Pinch仅限缩放图像

Hal*_*far 8 html jquery jquery-mobile pinchzoom cordova

我有一个工作JQM应用程序,我想在其中显示一些图像.图像当前在他们自己的iframe中,因此它们可以与应用程序分开滚动.

我希望能够仅缩放iframe中的图像.

我意识到如果我调整以下代码片段,我可以启用捏拉缩放,但这启用了整个应用程序.

<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;" />
Run Code Online (Sandbox Code Playgroud)

通过删除最大比例缩放缩放返回,但一切.

有没有办法只为图像启用捏拉缩放?如果可能的话,如果将新的视口标记添加到iframe,该工作会怎样?

UPDATE

  • 将HTML注入iframe.添加了元标记,这没有帮助.

  • 尝试.extend($.mobile.zoom,{locked:false,enabled:true}); 在iframe身上,这没有做任何事.

小智 5

你可以在图像上这样做:

var image=document.getElementById('imageId');

image.addEventListener('gesturechange',function(e){

    if(e.scale>1){
        //zoom in 
        //increase the size of image according to the e.scale
    }

    else if(e.scale<1){
        //zoom out 
        //decrease the size of image according to the e.scale
    }
});
Run Code Online (Sandbox Code Playgroud)


Hal*_*far 0

事实证明,最好的方法是使用 ChildBrowser 插件。这在 IOS 和 Android 上非常适合图像。

iOS 儿童浏览器:

 https://github.com/purplecabbage/phonegap-plugins/tree/master/iPhone/ChildBrowser
Run Code Online (Sandbox Code Playgroud)

Android 子浏览器:

 https://github.com/phonegap/phonegap-plugins/tree/master/Android/ChildBrowser
Run Code Online (Sandbox Code Playgroud)

完成所有设置后,您可以打开 URL 或本地文件,如下所示:

 window.plugins.childBrowser.onLocationChange(location);
Run Code Online (Sandbox Code Playgroud)

请注意,在 IOS 和 Android 之间的完全跨平台设置中,它们都需要不同版本的插件。IOS 需要在 onDeviceReady 中 init ChildBrowser,Android 不需要。