|
@@ -141,6 +141,7 @@ function doConnectDirectives() {
|
|
|
id: result.data.id,
|
|
|
width: result.data.width,
|
|
|
height: result.data.height,
|
|
|
+ pid: result.data.pid,
|
|
|
};
|
|
|
return;
|
|
|
}
|
|
@@ -179,11 +180,16 @@ function doConnectDirectives() {
|
|
|
if (result.type === 'getPhoneSize') {
|
|
|
// console.log(result);
|
|
|
const data = window.phoneSizeList.find(function (v) {
|
|
|
- return v.width === result.data.width && v.height === result.data.height;
|
|
|
+ return (
|
|
|
+ v.width === result.data.width &&
|
|
|
+ v.height === result.data.height &&
|
|
|
+ v.pid === result.data.pid
|
|
|
+ );
|
|
|
});
|
|
|
window.currentPhoneSize = data || {
|
|
|
width: result.data.width,
|
|
|
height: result.data.height,
|
|
|
+ pid: result.data.pid,
|
|
|
};
|
|
|
return;
|
|
|
}
|
|
@@ -239,49 +245,48 @@ var draw_graph = function (graphType) {
|
|
|
$('#dedit').css('z-index', 20);
|
|
|
// 先画在蒙版上 再复制到画布上
|
|
|
//鼠标按下获取 开始xy开始画图
|
|
|
- var ongoingTouches = [];
|
|
|
+ // var ongoingTouches = [];
|
|
|
var touchstart = function (e) {
|
|
|
+ console.log('🚀 ~ file: WXdraw.js ~ line 244 ~ touchstart ~ e', e);
|
|
|
if (!isControl) {
|
|
|
return;
|
|
|
}
|
|
|
$('.control-right-img').attr({
|
|
|
- 'data-id': '2',
|
|
|
+ 'data-id': '1',
|
|
|
});
|
|
|
$('.leftmains').css({
|
|
|
right: '-4rem',
|
|
|
});
|
|
|
- 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 * (window.currentPhoneSize.width / vowidth);
|
|
|
- var verticalHeightY =
|
|
|
- touchfor[i].pageY * (window.currentPhoneSize.height / 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, "pointerId": touchfor[i].identifier, "x": acrossWidthX.toFixed(2), "y": acrossHeightY.toFixed(2) }, "type": "event" } :
|
|
|
- {
|
|
|
+ const action = 0;
|
|
|
+ Array.from(e.originalEvent.changedTouches).forEach(function (item, index) {
|
|
|
+ const x = item.clientX - item.target.getBoundingClientRect().x;
|
|
|
+ const y = item.clientY - item.target.getBoundingClientRect().y;
|
|
|
+ return wsss.send(
|
|
|
+ JSON.stringify({
|
|
|
+ type: 'event',
|
|
|
data: {
|
|
|
- action: 0,
|
|
|
- count: ongoingTouches.length,
|
|
|
- pointerId: touchfor[i].identifier,
|
|
|
- x: verticalWidthX.toFixed(2),
|
|
|
- y: verticalHeightY.toFixed(2),
|
|
|
+ action,
|
|
|
+ count: e.originalEvent.touches.length,
|
|
|
+ pointerId: item.identifier,
|
|
|
+ x: (function () {
|
|
|
+ return (
|
|
|
+ resolving
|
|
|
+ ? x * (window.currentPhoneSize.width / vowidth)
|
|
|
+ : y * (window.currentPhoneSize.width / voheight)
|
|
|
+ ).toFixed(2);
|
|
|
+ })(),
|
|
|
+ y: (function () {
|
|
|
+ return (
|
|
|
+ resolving
|
|
|
+ ? y * (window.currentPhoneSize.height / voheight)
|
|
|
+ : (vowidth - x) * (window.currentPhoneSize.height / vowidth)
|
|
|
+ ).toFixed(2);
|
|
|
+ })(),
|
|
|
},
|
|
|
- type: 'event',
|
|
|
- };
|
|
|
- wsss.send(JSON.stringify(ping));
|
|
|
- }
|
|
|
+ }),
|
|
|
+ );
|
|
|
+ });
|
|
|
canDraw = true;
|
|
|
};
|
|
|
|
|
@@ -290,36 +295,82 @@ var draw_graph = function (graphType) {
|
|
|
if (!isControl) {
|
|
|
return;
|
|
|
}
|
|
|
- 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 * (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" } :
|
|
|
- {
|
|
|
+ const action = 1;
|
|
|
+ Array.from(e.originalEvent.changedTouches).forEach(function (item, index) {
|
|
|
+ const x = item.clientX - item.target.getBoundingClientRect().x;
|
|
|
+ const y = item.clientY - item.target.getBoundingClientRect().y;
|
|
|
+ return wsss.send(
|
|
|
+ JSON.stringify({
|
|
|
+ type: 'event',
|
|
|
data: {
|
|
|
- action: 1,
|
|
|
- count: ongoingTouches.length,
|
|
|
- pointerId: touchfor[i].identifier,
|
|
|
- x: verticalWidthX.toFixed(2),
|
|
|
- y: verticalHeightY.toFixed(2),
|
|
|
+ action,
|
|
|
+ count: e.originalEvent.touches.length,
|
|
|
+ pointerId: item.identifier,
|
|
|
+ x: (function () {
|
|
|
+ return (
|
|
|
+ resolving
|
|
|
+ ? x * (window.currentPhoneSize.width / vowidth)
|
|
|
+ : y * (window.currentPhoneSize.width / voheight)
|
|
|
+ ).toFixed(2);
|
|
|
+ })(),
|
|
|
+ y: (function () {
|
|
|
+ return (
|
|
|
+ resolving
|
|
|
+ ? y * (window.currentPhoneSize.height / voheight)
|
|
|
+ : (vowidth - x) * (window.currentPhoneSize.height / vowidth)
|
|
|
+ ).toFixed(2);
|
|
|
+ })(),
|
|
|
},
|
|
|
- type: 'event',
|
|
|
- };
|
|
|
- wsss.send(JSON.stringify(ping));
|
|
|
- ongoingTouches.forEach(function (item, index) {
|
|
|
- if (item.identifier === touchfor[i].identifier) {
|
|
|
- ongoingTouches.splice(index, 1);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
+ }),
|
|
|
+ );
|
|
|
+ });
|
|
|
+ // 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);
|
|
|
+ // // if (resolving) {
|
|
|
+ // // var verticalWidthX =
|
|
|
+ // // touchfor[i].pageX * (window.currentPhoneSize.width / vowidth);
|
|
|
+ // // var verticalHeightY =
|
|
|
+ // // touchfor[i].pageY * (window.currentPhoneSize.height / voheight);
|
|
|
+ // // } else {
|
|
|
+ // // 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: (() =>
|
|
|
+ // (resolving
|
|
|
+ // ? touchfor[i].pageX * (window.currentPhoneSize.width / vowidth)
|
|
|
+ // : touchfor[i].pageY * (window.currentPhoneSize.width / voheight)
|
|
|
+ // ).toFixed(2))(),
|
|
|
+ // y: (() =>
|
|
|
+ // (resolving
|
|
|
+ // ? touchfor[i].pageY *
|
|
|
+ // (window.currentPhoneSize.height / voheight)
|
|
|
+ // : (vowidth - touchfor[i].pageX) *
|
|
|
+ // (window.currentPhoneSize.height / vowidth)
|
|
|
+ // ).toFixed(2))(),
|
|
|
+ // },
|
|
|
+ // type: 'event',
|
|
|
+ // };
|
|
|
+ // wsss.send(JSON.stringify(ping));
|
|
|
+ // ongoingTouches.forEach(function (item, index) {
|
|
|
+ // if (item.identifier === touchfor[i].identifier) {
|
|
|
+ // ongoingTouches.splice(index, 1);
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // }
|
|
|
canDraw = false;
|
|
|
};
|
|
|
|
|
@@ -333,30 +384,79 @@ var draw_graph = function (graphType) {
|
|
|
if (!isControl) {
|
|
|
return;
|
|
|
}
|
|
|
- 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 * (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" } :
|
|
|
- {
|
|
|
+ const action = 2;
|
|
|
+ Array.from(e.originalEvent.changedTouches).forEach(function (item, index) {
|
|
|
+ const x = item.clientX - item.target.getBoundingClientRect().x;
|
|
|
+ const y = item.clientY - item.target.getBoundingClientRect().y;
|
|
|
+ return wsss.send(
|
|
|
+ JSON.stringify({
|
|
|
+ type: 'event',
|
|
|
data: {
|
|
|
- action: 2,
|
|
|
- count: touchfor.length,
|
|
|
- pointerId: touchfor[i].identifier,
|
|
|
- x: verticalWidthX.toFixed(2),
|
|
|
- y: verticalHeightY.toFixed(2),
|
|
|
+ action,
|
|
|
+ count: e.originalEvent.touches.length,
|
|
|
+ pointerId: item.identifier,
|
|
|
+ x: (function () {
|
|
|
+ return (
|
|
|
+ resolving
|
|
|
+ ? x * (window.currentPhoneSize.width / vowidth)
|
|
|
+ : y * (window.currentPhoneSize.width / voheight)
|
|
|
+ ).toFixed(2);
|
|
|
+ })(),
|
|
|
+ y: (function () {
|
|
|
+ return (
|
|
|
+ resolving
|
|
|
+ ? y * (window.currentPhoneSize.height / voheight)
|
|
|
+ : (vowidth - x) * (window.currentPhoneSize.height / vowidth)
|
|
|
+ ).toFixed(2);
|
|
|
+ })(),
|
|
|
},
|
|
|
- type: 'event',
|
|
|
- };
|
|
|
- wsss.send(JSON.stringify(ping));
|
|
|
- }
|
|
|
+ }),
|
|
|
+ );
|
|
|
+ });
|
|
|
+ // 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);
|
|
|
+
|
|
|
+ // // let verticalWidthX = 0;
|
|
|
+ // // let verticalHeightY = 0;
|
|
|
+ // // if (resolving) {
|
|
|
+ // // verticalWidthX =
|
|
|
+ // // touchfor[i].pageX * (window.currentPhoneSize.width / vowidth);
|
|
|
+ // // verticalHeightY =
|
|
|
+ // // touchfor[i].pageY * (window.currentPhoneSize.height / voheight);
|
|
|
+ // // } else {
|
|
|
+ // // verticalWidthX =
|
|
|
+ // // touchfor[i].pageX * (window.currentPhoneSize.width / vowidth);
|
|
|
+ // // 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: (() =>
|
|
|
+ // (resolving
|
|
|
+ // ? touchfor[i].pageX * (window.currentPhoneSize.width / vowidth)
|
|
|
+ // : touchfor[i].pageY * (window.currentPhoneSize.width / voheight)
|
|
|
+ // ).toFixed(2))(),
|
|
|
+ // y: (() =>
|
|
|
+ // (resolving
|
|
|
+ // ? touchfor[i].pageY *
|
|
|
+ // (window.currentPhoneSize.height / voheight)
|
|
|
+ // : (vowidth - touchfor[i].pageX) *
|
|
|
+ // (window.currentPhoneSize.height / vowidth)
|
|
|
+ // ).toFixed(2))(),
|
|
|
+ // },
|
|
|
+ // type: 'event',
|
|
|
+ // };
|
|
|
+ // wsss.send(JSON.stringify(ping));
|
|
|
+ // }
|
|
|
};
|
|
|
|
|
|
//鼠标离开区域以外 除了涂鸦 都清空
|