移动视口放大 [英] Mobile Viewport zoom back

查看:36
本文介绍了移动视口放大的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想让用户在点击图像时进行缩放,如果没有图像,我不想让他进行缩放.

I want to allow the user to zoom when he clicked on an image and I don't want to allow him to zoom if there is no image.

// image function 
viewport = document.querySelector("meta[name=viewport]");
viewport.setAttribute('content', 'width=device-width, initial-scale=1.0, maximum-scale=5.0, user-scalable=yes');

// no image function
viewport = document.querySelector("meta[name=viewport]");
viewport.setAttribute('content', 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no');

问题:如果用户可以缩放,他就不能回到正常禁用缩放,因为无图像功能会禁用缩放,但缩放系数不会返回正常视口.

The problem: If the user can zoom he can't go back to NORMAL disabled zoom because the no image function disables the zoom BUT the zoomfactor is not going back to the normal viewport.

所以在没有图像功能之后可以进行缩放,但已经有一个缩放系数:/

So after the no image function it is possible to zoom but there is a zoom-factor already :/

您知道如何在无图像功能中缩放回正常视口吗?谢谢!

Do you have any idea how to zoom back to the normal viewport in the no image function? Thanks!

推荐答案

不要改变视口.有更好的方法来实现同样的事情 -> http://lab.hakim.se/zoom-js/

Don't change the viewport. There is a better way to achieve the same thing -> http://lab.hakim.se/zoom-js/

我敢肯定,如果您使用这样的视口,您会在大多数移动设备上遇到问题.

I'm sure that if you play with the viewport like that you will have problems in most of the mobile devices.

这篇关于移动视口放大的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆