From 571bfc98f7a707a78f7ee09e87a96925af8513e8 Mon Sep 17 00:00:00 2001 From: zdg Date: Fri, 30 Aug 2024 13:35:25 +0800 Subject: [PATCH] =?UTF-8?q?bug:=20335=20=E4=BC=98=E5=8C=96=E5=8A=A8?= =?UTF-8?q?=E7=94=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/tool/components/side.vue | 24 +++++---- src/renderer/src/views/tool/directive/drag.js | 13 ++++- src/renderer/src/views/tool/sphere.vue | 52 +++++++++++++++---- 3 files changed, 65 insertions(+), 24 deletions(-) diff --git a/src/renderer/src/views/tool/components/side.vue b/src/renderer/src/views/tool/components/side.vue index 4da860f..341bb2f 100644 --- a/src/renderer/src/views/tool/components/side.vue +++ b/src/renderer/src/views/tool/components/side.vue @@ -2,17 +2,19 @@
- - - - + + + + + + {{isFold?'<<<':'>>>'}} diff --git a/src/renderer/src/views/tool/directive/drag.js b/src/renderer/src/views/tool/directive/drag.js index caa12f8..5565441 100644 --- a/src/renderer/src/views/tool/directive/drag.js +++ b/src/renderer/src/views/tool/directive/drag.js @@ -36,6 +36,7 @@ class Drag { const {cx, cy} = this.getMousePos(e) this.x = cx this.y = cy + this.getCurPos() // 被拖拽元素初始坐标 // 手动-触发事件 v-drag-start this.el.dispatchEvent(new CustomEvent('v-drag-start', {detail:{drag: this}})) } @@ -85,12 +86,20 @@ class Drag { } // 获取移动后坐标 getPos(x, y) { - const w = this.max.w - this.toRound(this.el.clientWidth) - const h = this.max.h - this.toRound(this.el.clientHeight) + // 边界控制:图标元素 + // const w = this.max.w - this.toRound(this.el.clientWidth) + // const h = this.max.h - this.toRound(this.el.clientHeight) + // 边界控制:整个工具 + const w = this.max.w - this.toRound(this.handle.clientWidth) + const h = this.max.h - this.toRound(this.handle.clientHeight) x = x < 0 ? 0 : x > w ? w : x y = y < 0 ? 0 : y > h ? h : y return { x, y } } + getCurPos(dom) { + const pos = this[dom||'handle']?.getBoundingClientRect() + this.data = {left:this.toRound(pos.left), top:this.toRound(pos.top)} + } // 小数转整数 toRound = v => Math.round(v) } diff --git a/src/renderer/src/views/tool/sphere.vue b/src/renderer/src/views/tool/sphere.vue index cef6cde..2848338 100644 --- a/src/renderer/src/views/tool/sphere.vue +++ b/src/renderer/src/views/tool/sphere.vue @@ -20,17 +20,19 @@
-
- - - -
+ +
+ + + +
+
@@ -109,6 +111,23 @@ const tabChange = (val) => { const logoHandle = (e,t) => { if (Date.now() - dragtime.value < 200) { isFold.value = !isFold.value + setTimeout(() => { + // 处理: 工具被拖动到右侧时功能被遮挡 + const dom = document.querySelector('.tool-bottom-all') + const { x } = dom.getBoundingClientRect() + const w = window.innerWidth - (470 || 80) + // if (x > w) dom.style.left = `${w}px` + if (x > w) { // 动画 + let left = x + const animatFn = () => { + left-=30 + if (left < w) left == w + dom.style.left = `${left}px` + if (left > w) requestAnimationFrame(animatFn) + } + requestAnimationFrame(animatFn) + } + }, 20); } } // 底部工具栏:移入移出-是否穿透 @@ -262,4 +281,15 @@ watchEffect(() => { } } } +.a-fade-leave-active,.a-fade-enter-active{ + transition: all .3s; +} +.a-fade-enter-from,.a-fade-leave-to{ + width: 0; + opacity: 0; +} +.a-fade-enter-to,.a-fade-leave-from{ + width: 350px; + opacity: 1; +}