From 99391c38af9811613db81dc495db0a00dd7d2a0e Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Wed, 09 Feb 2022 13:47:29 +0800
Subject: [PATCH] 部分修改

---
 src/pcviews/tool/ranging.vue |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 47 insertions(+), 0 deletions(-)

diff --git a/src/pcviews/tool/ranging.vue b/src/pcviews/tool/ranging.vue
index 01b829d..7c6f6de 100644
--- a/src/pcviews/tool/ranging.vue
+++ b/src/pcviews/tool/ranging.vue
@@ -32,6 +32,53 @@
     },
     created () { },
     methods: {
+        move (e) {
+            const that = this
+            const odiv = this.$refs.publicOrgNavBar // 获取目标元素
+            // 算出鼠标相对元素的位置
+            const disX = e.clientX - odiv.offsetLeft
+            const disY = e.clientY - odiv.offsetTop
+
+            const disH = odiv.offsetHeight
+            const disW = odiv.offsetWidth
+
+            document.onmousemove = (e) => {
+                that.moveFlag = true
+                // 鼠标按下并移动的事件
+                // 用鼠标的位置减去鼠标相对元素的位置,得到元素的位置
+                let left = e.clientX - disX
+                let top = e.clientY - disY
+
+                // 绑定元素位置到positionX和positionY上面
+
+                if (left >= window.innerWidth - disW) {
+                    left = window.innerWidth - disW
+                }
+
+                if (left <= 0) {
+                    left = 0
+                }
+
+                if (top >= window.innerHeight - disH) {
+                    top = window.innerHeight - disH
+                }
+
+                if (top <= 60) {
+                    top = 60
+                }
+
+                // 移动当前元素
+                odiv.style.left = (left) + 'px'
+                odiv.style.top = (top) + 'px'
+                odiv.style.bottom = 'auto'
+            }
+            document.onmouseup = (e) => {
+                that.moveFlag = false
+                document.onmousemove = null
+                document.onmouseup = null
+            }
+        },
+
         calcDistance () {
             this.viewer.measure.distanceSurface()
         },

--
Gitblit v1.9.3