Я работаю над мобильным интернет-магазином И застрял во время реализации функции масштабирования продукта
После щелчка на изображении разрешено "масштабируемое пользователем", а максимальное значение - 10,0 Когда пользователь нажимает на устройство с жестким жестом, все работает нормально. Но после закрытия увеличенного изображения масштаб не равен reset до 1.0.
Есть ли способ reset масштабировать значение окна просмотра динамически. "Начальная шкала", похоже, не работает, и не отменяет "минимальную шкалу" и "максимальную шкалу" до 1.0
Проблемы возникают на iPhone/iPad
Кажется, что есть решение, но я не знаю, к какому элементу я должен применить этот пост: Как reset масштабирование видового экрана без полного обновления страницы?
"Вам нужно использовать -webkit-transform: scale (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");
});