From c76d964ffd8ba6e2ea38f23909389cc83b5dce09 Mon Sep 17 00:00:00 2001 From: fangxiang Date: Fri, 15 Apr 2022 11:24:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=A7=A6=E6=91=B8=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=E4=BC=98=E5=85=88=E7=BA=A7=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/vue3-resize-drag/func/drag.ts | 30 ++++---- .../vue3-resize-drag/func/renderData.ts | 70 ++++++++++--------- .../vue3-resize-drag/func/resize.ts | 30 ++++---- .../components/vue3-resize-drag/index.vue | 15 ++-- 4 files changed, 80 insertions(+), 65 deletions(-) diff --git a/src/third_lib/vue3-resize-drag/components/vue3-resize-drag/func/drag.ts b/src/third_lib/vue3-resize-drag/components/vue3-resize-drag/func/drag.ts index 89f25ba..f3be967 100644 --- a/src/third_lib/vue3-resize-drag/components/vue3-resize-drag/func/drag.ts +++ b/src/third_lib/vue3-resize-drag/components/vue3-resize-drag/func/drag.ts @@ -55,17 +55,19 @@ const itemDrag = ( onmove(e); }; - if ("ontouchmove" in document.documentElement === true) { - document.ontouchmove = (e: TouchEvent) => { - if (e.changedTouches && e.changedTouches.length) { - onmove({ - movementX: 1, - movementY: 1, - clientX: e.changedTouches[0].clientX, - clientY: e.changedTouches[0].clientY, - }); - } - }; + if ((window).touchPriority) { + if ("ontouchmove" in document.documentElement === true) { + document.ontouchmove = (e: TouchEvent) => { + if (e.changedTouches && e.changedTouches.length) { + onmove({ + movementX: 1, + movementY: 1, + clientX: e.changedTouches[0].clientX, + clientY: e.changedTouches[0].clientY, + }); + } + }; + } } const onmoveend = (e: any) => { @@ -94,8 +96,10 @@ const itemDrag = ( }; document.onmouseup = onmoveend; - if ("ontouchend" in document.documentElement === true) { - document.ontouchend = (e) => onmoveend(e); + if ((window).touchPriority) { + if ("ontouchend" in document.documentElement === true) { + document.ontouchend = (e) => onmoveend(e); + } } }; export default itemDrag; diff --git a/src/third_lib/vue3-resize-drag/components/vue3-resize-drag/func/renderData.ts b/src/third_lib/vue3-resize-drag/components/vue3-resize-drag/func/renderData.ts index d506ffc..d71a254 100644 --- a/src/third_lib/vue3-resize-drag/components/vue3-resize-drag/func/renderData.ts +++ b/src/third_lib/vue3-resize-drag/components/vue3-resize-drag/func/renderData.ts @@ -30,78 +30,84 @@ function render(props: any) { transform: `rotate(${style.rotate}deg)`, }; }); + + // pad 放大拖拽的点 + let targetResizeIconSize = props.resizeIconSize; + if ((window).isPad) { + targetResizeIconSize *= 1.5; + } const dragElResizeIcon = computed(() => { return [ { class: "drag-lt", style: { - top: -(props.resizeIconSize / 2) + "px", - left: -(props.resizeIconSize / 2) + "px", - width: props.resizeIconSize + "px", - height: props.resizeIconSize + "px", + top: -(targetResizeIconSize / 2) + "px", + left: -(targetResizeIconSize / 2) + "px", + width: targetResizeIconSize + "px", + height: targetResizeIconSize + "px", }, }, { class: "drag-ct", style: { - top: -(props.resizeIconSize / 2) + "px", - left: style.width / 2 - props.resizeIconSize / 2 + "px", - width: props.resizeIconSize + "px", - height: props.resizeIconSize + "px", + top: -(targetResizeIconSize / 2) + "px", + left: style.width / 2 - targetResizeIconSize / 2 + "px", + width: targetResizeIconSize + "px", + height: targetResizeIconSize + "px", }, }, { class: "drag-rt", style: { - top: -(props.resizeIconSize / 2) + "px", - right: -(props.resizeIconSize / 2) + "px", - width: props.resizeIconSize + "px", - height: props.resizeIconSize + "px", + top: -(targetResizeIconSize / 2) + "px", + right: -(targetResizeIconSize / 2) + "px", + width: targetResizeIconSize + "px", + height: targetResizeIconSize + "px", }, }, { class: "drag-rc", style: { - top: style.height / 2 - props.resizeIconSize / 2 + "px", - right: -(props.resizeIconSize / 2) + "px", - width: props.resizeIconSize + "px", - height: props.resizeIconSize + "px", + top: style.height / 2 - targetResizeIconSize / 2 + "px", + right: -(targetResizeIconSize / 2) + "px", + width: targetResizeIconSize + "px", + height: targetResizeIconSize + "px", }, }, { class: "drag-rb", style: { - bottom: -(props.resizeIconSize / 2) + "px", - right: -(props.resizeIconSize / 2) + "px", - width: props.resizeIconSize + "px", - height: props.resizeIconSize + "px", + bottom: -(targetResizeIconSize / 2) + "px", + right: -(targetResizeIconSize / 2) + "px", + width: targetResizeIconSize + "px", + height: targetResizeIconSize + "px", }, }, { class: "drag-bc", style: { - bottom: -(props.resizeIconSize / 2) + "px", - left: style.width / 2 - props.resizeIconSize / 2 + "px", - width: props.resizeIconSize + "px", - height: props.resizeIconSize + "px", + bottom: -(targetResizeIconSize / 2) + "px", + left: style.width / 2 - targetResizeIconSize / 2 + "px", + width: targetResizeIconSize + "px", + height: targetResizeIconSize + "px", }, }, { class: "drag-lb", style: { - bottom: -(props.resizeIconSize / 2) + "px", - left: -(props.resizeIconSize / 2) + "px", - width: props.resizeIconSize + "px", - height: props.resizeIconSize + "px", + bottom: -(targetResizeIconSize / 2) + "px", + left: -(targetResizeIconSize / 2) + "px", + width: targetResizeIconSize + "px", + height: targetResizeIconSize + "px", }, }, { class: "drag-lc", style: { - top: style.height / 2 - props.resizeIconSize / 2 + "px", - left: -(props.resizeIconSize / 2) + "px", - width: props.resizeIconSize + "px", - height: props.resizeIconSize + "px", + top: style.height / 2 - targetResizeIconSize / 2 + "px", + left: -(targetResizeIconSize / 2) + "px", + width: targetResizeIconSize + "px", + height: targetResizeIconSize + "px", }, }, ]; diff --git a/src/third_lib/vue3-resize-drag/components/vue3-resize-drag/func/resize.ts b/src/third_lib/vue3-resize-drag/components/vue3-resize-drag/func/resize.ts index 3c62b0c..876ad46 100644 --- a/src/third_lib/vue3-resize-drag/components/vue3-resize-drag/func/resize.ts +++ b/src/third_lib/vue3-resize-drag/components/vue3-resize-drag/func/resize.ts @@ -100,17 +100,19 @@ const itemResize = ( }; document.onmousemove = onmove; - if ("ontouchmove" in document.documentElement === true) { - document.ontouchmove = (e: TouchEvent) => { - if (e.changedTouches && e.changedTouches.length) { - onmove({ - movementX: 1, - movementY: 1, - clientX: e.changedTouches[0].clientX, - clientY: e.changedTouches[0].clientY, - }); - } - }; + if ((window).touchPriority) { + if ("ontouchmove" in document.documentElement === true) { + document.ontouchmove = (e: TouchEvent) => { + if (e.changedTouches && e.changedTouches.length) { + onmove({ + movementX: 1, + movementY: 1, + clientX: e.changedTouches[0].clientX, + clientY: e.changedTouches[0].clientY, + }); + } + }; + } } const onmoveend = (e: any) => { @@ -139,8 +141,10 @@ const itemResize = ( }; document.onmouseup = onmoveend; - if ("ontouchend" in document.documentElement === true) { - document.ontouchend = (e) => onmoveend(e); + if ((window).touchPriority) { + if ("ontouchend" in document.documentElement === true) { + document.ontouchend = (e) => onmoveend(e); + } } }; export default itemResize; diff --git a/src/third_lib/vue3-resize-drag/components/vue3-resize-drag/index.vue b/src/third_lib/vue3-resize-drag/components/vue3-resize-drag/index.vue index 1f1f2f1..0837aad 100644 --- a/src/third_lib/vue3-resize-drag/components/vue3-resize-drag/index.vue +++ b/src/third_lib/vue3-resize-drag/components/vue3-resize-drag/index.vue @@ -31,7 +31,6 @@