|

楼主 |
发表于 2017-9-7 18:01:24
|
显示全部楼层
本帖最后由 xiaowenwu 于 2017-9-7 18:02 编辑
这个案例不是一般的坑,,求修改好、、、、我的已经好了,修改如下,注释掉了好多代码。。。
Model.prototype.pinch = function(event){
var me=this;
var id = this.getIDByXID('pinch');
var posData=me.comp("posData");
var target = document.getElementById(id);
touch.on('#' + id, 'touchstart', function(ev){
/* ev.preventDefault();*/
ev.target=target;
});
var initialScale = 1;
touch.on('#' + id, 'pinch', function(ev){
/*
this.style.webkitTransform = "translate3d(0,0,0)";
ev.hasStopedPropagation = true;*/
currentScale = ev.scale - 1;
currentScale = initialScale + currentScale;
currentScale = currentScale > 4 ? 4 : currentScale;//最大倍数2
currentScale = currentScale < 1 ? 1 : currentScale;//最小倍数1
currentScale = currentScale < 1 ? 1 : currentScale;
/*var y=this;
while(me.getElementByXid('pinch') != y){
y = y.parentNode;
}*/
target.style.webkitTransform = 'scale(' + currentScale + ')';
});
touch.on('#' + id, 'pinchend', function(ev){
initialScale = currentScale;
});
var dx, dy;
touch.on('#' + id, 'drag', function(ev){
var x=this;
dx = dx || 0;
dy = dy || 0;
var offx =dx+ ev.x*0.5 + "px";
var offy =dy+ev.y*0.5 + "px";
target.style.webkitTransform = "scale(" + initialScale + ")" + "translate3d(" + offx + "," + offy + ",0)";
});
touch.on('#' + id, 'dragend', function(ev){
dx += ev.x;
dy += ev.y;
});
}; |
|