Explorar o código

feat(分辨率): 修改触控坐标转换

zengzhixiang %!s(int64=3) %!d(string=hai) anos
pai
achega
29d9d2befb
Modificáronse 2 ficheiros con 99 adicións e 83 borrados
  1. 87 78
      static/screenAndroid/WXdraw.js
  2. 12 5
      static/screenIos/WXdraw.js

+ 87 - 78
static/screenAndroid/WXdraw.js

@@ -233,11 +233,13 @@ var draw_graph = function (graphType, obj) {
     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 acrossWidthX = touchfor[i].pageY * (videoHeight / voheight);
+      // var acrossHeightY =
+      //   videoWidth - touchfor[i].pageX * (videoWidth / vowidth);
+      var verticalWidthX =
+        touchfor[i].pageX * (window.currentPhoneSize.width / vowidth);
+      var verticalHeightY =
+        touchfor[i].pageY * (window.currentPhoneSize.width / voheight);
       var idx = ongoingTouches.findIndex(function (ele) {
         return ele.identifier === touchfor[i].identifier;
       });
@@ -245,27 +247,28 @@ var draw_graph = function (graphType, obj) {
         ongoingTouches.push(touchfor[i]);
       }
       var ping =
-        resolving == 0
-          ? {
-              data: {
-                action: 0,
-                count: ongoingTouches.length,
-                pointerId: touchfor[i].identifier,
-                x: acrossWidthX.toFixed(2),
-                y: acrossHeightY.toFixed(2),
-              },
-              type: 'event',
-            }
-          : {
-              data: {
-                action: 0,
-                count: ongoingTouches.length,
-                pointerId: touchfor[i].identifier,
-                x: verticalWidthX.toFixed(2),
-                y: verticalHeightY.toFixed(2),
-              },
-              type: 'event',
-            };
+        // resolving == 0
+        //   ? {
+        //       data: {
+        //         action: 0,
+        //         count: ongoingTouches.length,
+        //         pointerId: touchfor[i].identifier,
+        //         x: acrossWidthX.toFixed(2),
+        //         y: acrossHeightY.toFixed(2),
+        //       },
+        //       type: 'event',
+        //     }
+        //   :
+        {
+          data: {
+            action: 0,
+            count: ongoingTouches.length,
+            pointerId: touchfor[i].identifier,
+            x: verticalWidthX.toFixed(2),
+            y: verticalHeightY.toFixed(2),
+          },
+          type: 'event',
+        };
       wsss.send(JSON.stringify(ping));
     }
     canDraw = true;
@@ -279,33 +282,36 @@ var draw_graph = function (graphType, obj) {
     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 acrossWidthX = touchfor[i].pageY * (videoHeight / voheight);
+      // var acrossHeightY =
+      //   videoWidth - touchfor[i].pageX * (videoWidth / vowidth);
+      var verticalWidthX =
+        touchfor[i].pageX * (window.currentPhoneSize.width / vowidth);
+      var verticalHeightY =
+        touchfor[i].pageY * (window.currentPhoneSize.height / voheight);
       var ping =
-        resolving == 0
-          ? {
-              data: {
-                action: 1,
-                count: ongoingTouches.length,
-                pointerId: touchfor[i].identifier,
-                x: acrossWidthX.toFixed(2),
-                y: acrossHeightY.toFixed(2),
-              },
-              type: 'event',
-            }
-          : {
-              data: {
-                action: 1,
-                count: ongoingTouches.length,
-                pointerId: touchfor[i].identifier,
-                x: verticalWidthX.toFixed(2),
-                y: verticalHeightY.toFixed(2),
-              },
-              type: 'event',
-            };
+        // resolving == 0
+        //   ? {
+        //       data: {
+        //         action: 1,
+        //         count: ongoingTouches.length,
+        //         pointerId: touchfor[i].identifier,
+        //         x: acrossWidthX.toFixed(2),
+        //         y: acrossHeightY.toFixed(2),
+        //       },
+        //       type: 'event',
+        //     }
+        //   :
+        {
+          data: {
+            action: 1,
+            count: ongoingTouches.length,
+            pointerId: touchfor[i].identifier,
+            x: verticalWidthX.toFixed(2),
+            y: verticalHeightY.toFixed(2),
+          },
+          type: 'event',
+        };
       wsss.send(JSON.stringify(ping));
       ongoingTouches.forEach(function (item, index) {
         if (item.identifier === touchfor[i].identifier) {
@@ -328,33 +334,36 @@ var draw_graph = function (graphType, obj) {
     }
     var touchfor = e.originalEvent.targetTouches; //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 acrossWidthX = touchfor[i].pageY * (videoHeight / voheight);
+      // var acrossHeightY =
+      //   videoWidth - touchfor[i].pageX * (videoWidth / vowidth);
+      var verticalWidthX =
+        touchfor[i].pageX * (window.currentPhoneSize.width / vowidth);
+      var verticalHeightY =
+        touchfor[i].pageY * (window.currentPhoneSize.height / voheight);
       var ping =
-        resolving == 0
-          ? {
-              data: {
-                action: 2,
-                count: touchfor.length,
-                pointerId: touchfor[i].identifier,
-                x: acrossWidthX.toFixed(2),
-                y: acrossHeightY.toFixed(2),
-              },
-              type: 'event',
-            }
-          : {
-              data: {
-                action: 2,
-                count: touchfor.length,
-                pointerId: touchfor[i].identifier,
-                x: verticalWidthX.toFixed(2),
-                y: verticalHeightY.toFixed(2),
-              },
-              type: 'event',
-            };
+        // resolving == 0
+        //   ? {
+        //       data: {
+        //         action: 2,
+        //         count: touchfor.length,
+        //         pointerId: touchfor[i].identifier,
+        //         x: acrossWidthX.toFixed(2),
+        //         y: acrossHeightY.toFixed(2),
+        //       },
+        //       type: 'event',
+        //     }
+        //   :
+        {
+          data: {
+            action: 2,
+            count: touchfor.length,
+            pointerId: touchfor[i].identifier,
+            x: verticalWidthX.toFixed(2),
+            y: verticalHeightY.toFixed(2),
+          },
+          type: 'event',
+        };
       wsss.send(JSON.stringify(ping));
     }
   };

+ 12 - 5
static/screenIos/WXdraw.js

@@ -256,8 +256,11 @@ var draw_graph = function (graphType) {
       // 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 verticalWidthX =
+        touchfor[i].pageX * (window.currentPhoneSize.width / vowidth);
+      var verticalHeightY =
+        touchfor[i].pageY * (window.currentPhoneSize.width / voheight);
       var idx = ongoingTouches.findIndex(function (ele) {
         return ele.identifier === touchfor[i].identifier;
       });
@@ -293,8 +296,10 @@ var draw_graph = function (graphType) {
       // 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 verticalWidthX =
+        touchfor[i].pageX * (window.currentPhoneSize.width / vowidth);
+      var verticalHeightY =
+        touchfor[i].pageY * (window.currentPhoneSize.height / voheight);
       var ping =
         // resolving == 0 ?
         //   { "data": { "action": 1, "count": ongoingTouches.length, "pointerId": touchfor[i].identifier, "x": acrossWidthX.toFixed(2), "y": acrossHeightY.toFixed(2) }, "type": "event" } :
@@ -333,8 +338,10 @@ var draw_graph = function (graphType) {
       // var acrossWidthX = touchfor[i].pageY * (videoHeight / voheight);
       // var acrossHeightY =
       //   videoWidth - touchfor[i].pageX * (videoWidth / vowidth);
-      var verticalWidthX = touchfor[i].pageX * (videoWidth / vowidth);
+      var verticalWidthX =
+        touchfor[i].pageX * (window.currentPhoneSize.width / vowidth);
       var verticalHeightY = touchfor[i].pageY * (videoHeight / voheight);
+      window.currentPhoneSize.height;
       var ping =
         // resolving == 0 ?
         //   { "data": { "action": 2, "count": touchfor.length, "pointerId": touchfor[i].identifier, "x": acrossWidthX.toFixed(2), "y": acrossHeightY.toFixed(2) }, "type": "event" } :