meta name="viewport"
当设置为时,如何检测缩放的缩放比例(或缩放距离)user-scalable=yes
?
我已经在 Android 上进行了测试,但如果meta name="viewport"
设置为user-scalable=yes
. 如果meta name="viewport"
设置为,user-scalable=no
则可以检测到缩放缩放,但我无法放大文档。
这是我对 jsFiddle 的测试:
Hammer.js:http: //jsfiddle.net/pE42S/
var pziW = "test";
var viewport_width = $(window).innerWidth();
var zoom = 0;
var hammer = new Hammer(document.getElementById("touchme"));
hammer.ontransformstart = function(ev) {
console.log("ontransformstart");
console.log(ev);
//pziW = $(window).innerWidth() / 2 * ev.scale;
zoom = ev.scale;
var msg = "ontransformstart " + pziW + " scale " + zoom;
log(msg);
};
hammer.ontransform = function(ev) {
console.log("ontransform");
console.log(ev);
zoom -= ev.scale;
viewport_width+=viewport_width*zoom;
zoom = ev.scale;
pziW=viewport_width;
//pziW = $(window).innerWidth() / 2 * ev.scale;
jqUpdateSize();
var msg = "ontransform " + pziW + " scale " + zoom;
log(msg);
};
hammer.ontransformend = function(ev) {
console.log("ontransformend");
console.log(ev);
var msg = "ontransformend " + pziW + " scale " + zoom;
log(msg);
};
TouchSwipe:http: //jsfiddle.net/pE42S/1/
$(function() {
$("#touchme").swipe( {
pinchStatus:function(event, phase, direction, distance , duration , fingerCount, pinchZoom) {
console.log("pinchStatus");
console.log(event);
pziW=viewport_width - distance;
$("#log").text(pziW);
jqUpdateSize();
},
fingers:2,
pinchThreshold:0
});
});
有人有答案吗?