问题
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