Mobile Viewport zoom back

最后都变了- 提交于 2019-12-11 22:04:44

问题


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!


回答1:


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.



来源:https://stackoverflow.com/questions/18696251/mobile-viewport-zoom-back

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!