|
在原生js 中写mousedown事件中可以再定义mousemove,mouseup事件,在wex5中应该怎么写呢?
document.onmousedown = function(e){
var lastX=e.clientX,lastY=e.clientY;
this.onmousemove = function(e){
console.log(e.clientX,e.clientY);
var newX=e.clientX,newY=e.clientY;
var dX = newX-lastX,dY=newY-lastY;
rY+=dX*0.1,rX-=dY*0.1;
wrap.style.transform = "rotateX("+rX+"deg) rotateY("+rY+"deg)"
lastX=newX,lastY=newY;
}
this.onmouseup = function(){
console.log("up")
this.onmousemove = null;
}
} |
|