|
@@ -34,17 +34,15 @@
|
|
|
|
|
|
function changes() {
|
|
function changes() {
|
|
can.addEventListener('touchstart', function (el) {
|
|
can.addEventListener('touchstart', function (el) {
|
|
- startMouse.x = el.touches[0].pageX;
|
|
|
|
- startMouse.y = el.touches[0].pageX;
|
|
|
|
- console.log("起点:"+startMouse.x+"==="+startMouse.y);
|
|
|
|
|
|
+ let rect = el.target.getBoundingClientRect();
|
|
|
|
+ startMouse.x = el.touches[0].pageX - rect.left;
|
|
|
|
+ startMouse.y = el.touches[0].pageY - rect.top;
|
|
calcStartRadius();
|
|
calcStartRadius();
|
|
can.addEventListener('touchmove', function (e) {
|
|
can.addEventListener('touchmove', function (e) {
|
|
moveMouse.x = startMouse.x;
|
|
moveMouse.x = startMouse.x;
|
|
moveMouse.y = startMouse.y;
|
|
moveMouse.y = startMouse.y;
|
|
startMouse.x = e.targetTouches[0].pageX - this.offsetLeft;
|
|
startMouse.x = e.targetTouches[0].pageX - this.offsetLeft;
|
|
startMouse.y = e.targetTouches[0].pageY - this.offsetTop;
|
|
startMouse.y = e.targetTouches[0].pageY - this.offsetTop;
|
|
- /* console.log("last_mouse.x="+moveMouse.x);
|
|
|
|
- console.log("last_mouse.y="+moveMouse.y);*/
|
|
|
|
if(startMouse.x !== moveMouse.x && startMouse.y !== moveMouse.y){
|
|
if(startMouse.x !== moveMouse.x && startMouse.y !== moveMouse.y){
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -56,6 +54,10 @@
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ function calcOffset(){
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
/*计算起始点*/
|
|
/*计算起始点*/
|
|
function calcStartRadius(){
|
|
function calcStartRadius(){
|
|
let sum = Math.pow(startMouse.x-CENTER_X, 2)+ Math.pow(CENTER_Y-startMouse.y, 2);
|
|
let sum = Math.pow(startMouse.x-CENTER_X, 2)+ Math.pow(CENTER_Y-startMouse.y, 2);
|