Bladeren bron

多点触控

huangxiaojing 3 jaren geleden
bovenliggende
commit
c55f131d68
1 gewijzigde bestanden met toevoegingen van 8 en 3 verwijderingen
  1. 8 3
      screenAndroid/WXdraw.js

+ 8 - 3
screenAndroid/WXdraw.js

@@ -185,11 +185,16 @@ var draw_graph = function (graphType, obj) {
       var acrossHeightY = videoWidth - touchfor[i].pageX * (videoWidth / vowidth);
       var verticalWidthX = touchfor[i].pageX * (videoWidth / vowidth);
       var verticalHeightY = touchfor[i].pageY * (videoHeight / voheight);
+      var idx = ongoingTouches.findIndex(function (ele) {
+        return ele.identifier === touchfor[i].identifier
+      })
+      if (idx < 0) {
+        ongoingTouches.push(touchfor[i]);
+      }
       var ping = resolving == 0 ?
         { "data": { "action": 0, "count": ongoingTouches.length, "id": touchfor[i].identifier, "x": acrossWidthX.toFixed(2), "y": acrossHeightY.toFixed(2) }, "type": "event" } :
         { "data": { "action": 0, "count": ongoingTouches.length, "id": touchfor[i].identifier, "x": verticalWidthX.toFixed(2), "y": verticalHeightY.toFixed(2) }, "type": "event" };
       console.log(ping);
-      ongoingTouches.push(ping);
       wsss.send(JSON.stringify(ping));
     }
     canDraw = true;
@@ -209,8 +214,8 @@ var draw_graph = function (graphType, obj) {
         { "data": { "action": 1, "count": ongoingTouches.length, "id": touchfor[i].identifier, "x": verticalWidthX.toFixed(2), "y": verticalHeightY.toFixed(2) }, "type": "event" };
       console.log(ping);
       wsss.send(JSON.stringify(ping));
-      ongoingTouches.forEach(function(item, index) {
-        if (item.id === touchfor[i].identifier) {
+      ongoingTouches.forEach(function (item, index) {
+        if (item.identifier === touchfor[i].identifier) {
           ongoingTouches.splice(index, 1)
         }
       })