我想知道缩放时缩放的innerWith/viewport宽度。
如果它低于 500 像素,我想更改图像:
$("img#ad").attr("src", "http://img0.www.suckmypic.net/img/1/L/mmy4jT8s/jsFiddle3.png");
我试过这样的事情:
var hammer = new Hammer(document.getElementById("log"));
hammer.ontransformstart = function(ev) {
var pziW = "test"; // Declare here the innerWidth of the pinch to zoom
if (pziW < 500) {
$("img#ad").attr("src", "http://img0.www.suckmypic.net/img/1/L/mmy4jT8s/jsFiddle3.png");
}
};
hammer.ontransform = function(ev) {
var pziW = "test"; // Declare here the innerWidth of the pinch to zoom
if (pziW < 500) {
$("img#ad").attr("src", "http://img0.www.suckmypic.net/img/1/L/mmy4jT8s/jsFiddle3.png");
}
};
hammer.ontransformend = function(ev) {
var pziW = "test"; // Declare here the innerWidth of the pinch to zoom
if (pziW < 500) {
$("img#ad").attr("src", "http://img0.www.suckmypic.net/img/1/L/mmy4jT8s/jsFiddle3.png");
}
};
但我不知道如何声明缩放的innerWidth。
这是jsFiddle:
有人有答案吗?