ImはAAモバイルオンラインストアに取り組んでおり、「ユーザースケーラブルな」画像をクリックすると、製品のズーム機能動的1.0
を実装しながら、行き詰まっにビューポートの尺度をリセットする方法はありますが許可され、最大スケールは10.0に設定されています。 ピンチジェスチャーでユーザーが製品をズームすると、すべて正常に動作します。 ズームした画像を閉じると、スケールは1.0にリセットされません。
ビューポートのスケール値を動的にリセットする方法はありますか? 「初期スケールは」動作しないようですが、どちらも1.0
に問題を「最小スケール」および「最大規模」をresetingんが、iPhone/iPadの
に発生した解決策があるようです How to reset viewport scaling without full page refresh?
は:が、私はこの記事に適用する必要のある要素か分からない「あなたは-webkit-変換を使用する必要があります。スケール(1.1); WebKitの移行を」
しかし、スタイルが適用される要素はわかりません。
問題を説明するためのコードです。ビューポートのためのメタタグに
は次のようになります。
<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
興味があれば、私は答えを書いています(こちら)[https://stackoverflow.com/questions/22639296/force-mobileこの正確な問題については、-browser-zoom-out-javascript/46137189#46137189]をご覧ください。あなたの質問に答えて見つけたすべての解決法または他の質問に反する(私のための)解決策。 –