進出口工作在AA移動在線商店,而實現產品的變焦功能有沒有辦法到視規模重置動態1.0
點擊圖像「用戶可升級」後陷是允許的,最大比例設置爲10.0 當用戶用捏手勢放大產品時,一切正常。 但是在關閉縮放圖像後,縮放不會重置爲1.0。
有沒有辦法重置視口的比例值動態。 「初始規模」似乎不工作,既不確實正在重置「最低級」以及「最大規模」至1.0
的問題發生在iPhone/iPad的
似乎有一個解決方案,但我不知道哪一個元素,我應該使用對這個職位: How to reset viewport scaling without full page refresh?
「您需要使用-webkit-變換:規模(1.1); WebKit的過渡」
但我不知道風格應用於哪個元素。
下面是一些代碼來說明問題。
在視口的meta標籤是這樣的:
<meta name="viewport" content="user-scalable=no, width=device-width, height=device-height, minimum-scale=1.0, maximum-scale=1.0" />
頁面的其餘部分是這樣的:
<div id="page">
<img src="images/smallProductImage.jpg">
</div>
<div id="zoom">
<div class="jsZoomImageContainer"></div>
</div>
,這是JavaScript ::
zoom:{
img: null,
initialScreen:null,
load:function(src){
//load the image and show it when loaded
showLoadingAnimation();
this.img = new Image();
this.img.src = src;
jQuery(this.img).load(function(){
zoom.show();
});
},
show:function(){
var screenWidth, screenHeight, imageWidth, imageHeight, scale, ctx;
hideLoadingAnimation();
jQuery("#page").hide();
jQuery("#zoom").show();
jQuery(".jsZoomImageContainer").empty();
this.initialScreen =[jQuery(window).width(), jQuery(window).height()]
jQuery(".jsZoomImageContainer").append(this.img);
imageWidth = jQuery(this.img).width();
imageHeight = jQuery(this.img).height();
scale = this.initialScreen[0]/imageWidth ;
jQuery(this.img).width(imageWidth * scale)
jQuery(this.img).height(imageHeight * scale)
jQuery(".jsZoomImageContainer").click(function(){
zoom.hide();
});
jQuery('meta[name="viewport"]',"head").attr("content","user-scalable=yes, initial-scale:1.0, minimum-scale=1.0, maximum-scale=10.0")
},
hide:function(){
jQuery(".jsZoomImageContainer").empty();
jQuery('meta[name="viewport"]',"head").attr("content","user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0")
jQuery("#zoom").hide();
jQuery("#page").show();
this.img = null;
this.initialScreen = null;
}
}
jQuery("#page img").click(function(){
zoom.load("images/bigProductImage.jpg");
});
您提到的解決方案使用CSS縮放事物,而不是應用於視口的原生縮放。如果你想應用該解決方案,你應該重新考慮你的縮放,所以它是通過css + javascript – BBog 2012-07-27 15:07:55
如果你有興趣,我寫了一個答案(在這裏)[https://stackoverflow.com/questions/22639296/force-mobile瀏覽器縮小與JavaScript/46137189#46137189]關於這個確切的問題。一種解決方案適用於(對我來說)違反所有解答您的問題或其他問題的解決方案。 – 2017-09-10 04:05:21