chinatjnet / ztouch Goto Github PK
View Code? Open in Web Editor NEWZepto.js v1.0.1 touch extend (Zepto.js v1.0.1 swipe/touch扩展)
Home Page: http://chinatjnet.github.io/zTouch/
Zepto.js v1.0.1 touch extend (Zepto.js v1.0.1 swipe/touch扩展)
Home Page: http://chinatjnet.github.io/zTouch/
RT
建议换成 translateX()
初始化时候定下了边界的四个点。如果后来页面动态加载导致container位置发生了变化。会导致事件move回调无法正常触发。
先支持一个!
我想做图片的缩放,旋转和拖动位置,目前试验到旋转,代码如下
mCallback:function(tPoint){
var _this=tPoint.self,
img=_this.find("img");
if(tPoint.mutiTouch){
if(!tPoint.startScale){
tPoint.setAttr("startScale",1);
tPoint.setAttr("startRotation",0);
}else{
_curScale=tPoint.startScale_tPoint.scale;
_curRotation=tPoint.startRotation+tPoint.rotation;
// img.css("-webkit-transform-origin","0 0");
img.css({
// width: _curScale_100+"%",
'-webkit-transform': 'scale('+_curScale+') rotate('+_curRotation+'deg)'
});
tPoint.setAttr("curScale",_curScale);
//$("#showT").html("起始缩放:"+tPoint.startScale+"
当前缩放:"+tPoint.curScale);
$("#showT").html("手势缩放比例:"+_curScale+"
旋转角度:"+tPoint.rotation);
}
}
//$("#showT").html(tPoint.gStartDis+" "+tPoint.gEndDis);
//$("#showT").html(tPoint.rotation+" "+tPoint.gStartAngle+" "+tPoint.gEndAngle);
},
eCallback:function(tPoint){
if(tPoint.curScale){
tPoint.setAttr("startScale",tPoint.curScale);
tPoint.setAttr("startRotation",_curRotation);
}
}
我用的-webkit-transform的scale 和rotate 来做的,但是有个小bug。
当我监测tPoint.rotatioin的时候,发现一个规律,就是在第一次开始转动的方向上,角度最多到达140度,就瞬间变成-40度 差总在180度。这样会造成图片的跳动,怎么破?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.