浏览代码

多点触控

huangxiaojing 3 年之前
父节点
当前提交
74cc7c5b14
共有 2 个文件被更改,包括 7 次插入7 次删除
  1. 5 5
      screenAndroid/WXdraw.js
  2. 2 2
      screenIos/WXdraw.js

+ 5 - 5
screenAndroid/WXdraw.js

@@ -177,7 +177,7 @@ var draw_graph = function (graphType, obj) {
     $(".leftmains").css({
       "right": "-4rem"
     })
-    var touchfor = e.originalEvent.touches; //for 的手指数组
+    var touchfor = e.originalEvent.changedTouches; //for 的手指数组
     //是否横屏
     for (var i = 0; i < touchfor.length; i++) {
       var acrossWidthX = touchfor[i].pageY * (videoHeight / voheight);
@@ -195,7 +195,7 @@ var draw_graph = function (graphType, obj) {
 
   //鼠标离开 把蒙版canvas的图片生成到canvas中
   var touchend = function (e) {
-    var touchfor = e.originalEvent.touches; //for 的手指数组
+    var touchfor = e.originalEvent.changedTouches; //for 的手指数组
     //是否横屏
     for (var i = 0; i < touchfor.length; i++) {
       var acrossWidthX = touchfor[i].pageY * (videoHeight / voheight);
@@ -218,15 +218,15 @@ var draw_graph = function (graphType, obj) {
 
   // 鼠标移动
   var touchmove = function (e) {
-    var touchfor = e.originalEvent.touches; //for 的手指数组
+    var touchfor = e.originalEvent.changedTouches; //for 的手指数组
     for (var i = 0; i < touchfor.length; i++) {
       var acrossWidthX = touchfor[i].pageY * (videoHeight / voheight);
       var acrossHeightY = videoWidth - touchfor[i].pageX * (videoWidth / vowidth);
       var verticalWidthX = touchfor[i].pageX * (videoWidth / vowidth);
       var verticalHeightY = touchfor[i].pageY * (videoHeight / voheight);
       var ping = resolving == 0 ?
-        { "data": { "action": 2, "count": touchfor[i].length, "id": touchfor[i].identifier, "x": acrossWidthX.toFixed(2), "y": acrossHeightY.toFixed(2) }, "type": "event" } :
-        { "data": { "action": 2, "count": touchfor[i].length, "id": touchfor[i].identifier, "x": verticalWidthX.toFixed(2), "y": verticalHeightY.toFixed(2) }, "type": "event" };
+        { "data": { "action": 2, "count": touchfor.length, "id": touchfor[i].identifier, "x": acrossWidthX.toFixed(2), "y": acrossHeightY.toFixed(2) }, "type": "event" } :
+        { "data": { "action": 2, "count": touchfor.length, "id": touchfor[i].identifier, "x": verticalWidthX.toFixed(2), "y": verticalHeightY.toFixed(2) }, "type": "event" };
       console.log(ping);
       wsss.send(JSON.stringify(ping));
     }

+ 2 - 2
screenIos/WXdraw.js

@@ -224,8 +224,8 @@ var draw_graph = function (graphType) {
       var verticalWidthX = touchfor[i].pageX * (videoWidth / vowidth);
       var verticalHeightY = touchfor[i].pageY * (videoHeight / voheight);
       var ping = resolving == 0 ?
-        { "data": { "action": 2, "count": touchfor[i].length, "id": touchfor[i].identifier, "x": acrossWidthX.toFixed(2), "y": acrossHeightY.toFixed(2) }, "type": "event" } :
-        { "data": { "action": 2, "count": touchfor[i].length, "id": touchfor[i].identifier, "x": verticalWidthX.toFixed(2), "y": verticalHeightY.toFixed(2) }, "type": "event" };
+        { "data": { "action": 2, "count": touchfor.length, "id": touchfor[i].identifier, "x": acrossWidthX.toFixed(2), "y": acrossHeightY.toFixed(2) }, "type": "event" } :
+        { "data": { "action": 2, "count": touchfor.length, "id": touchfor[i].identifier, "x": verticalWidthX.toFixed(2), "y": verticalHeightY.toFixed(2) }, "type": "event" };
       console.log(ping);
       wsss.send(JSON.stringify(ping));
     }