From 91731d91e61e6260b86973500b76306be304bf8e Mon Sep 17 00:00:00 2001
From: 6401beb03f7e77205359be50 <6401beb03f7e77205359be50@devide>
Date: Tue, 30 May 2023 06:59:18 +0000
Subject: [PATCH] Auto Commit
---
src/App.vue | 171 +++++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 136 insertions(+), 35 deletions(-)
diff --git a/src/App.vue b/src/App.vue
index 633a5df..b257cc3 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -1,47 +1,148 @@
+
+
+

+
+
+
+import {ref, nextTick} from "vue"
-
-
-
+nextTick(() => {
+ if(isWebPlatform()) initDrag()
+ else initDrag1()
+})
+/*
+注意事项:
+1. 父元素的宽高、元素在其内内移动。
+2. 拖拽和点击事件的冲突解决、使用时间戳
+3. 图片拖拽时候不可拖拽、阻止默认事件
+* */
-
-
-
-
+//pc端
+let time = 0
+const initDrag = () => {
+ const dragBox = document.getElementsByClassName('drag-box')[0]
+ const dragParent = dragBox.offsetParent
-
-
-
-
+ let maxX = dragParent.offsetWidth - dragBox.offsetWidth
+ let maxY = dragParent.offsetHeight - dragBox.offsetHeight
-
+
+.drag-box {
+ width: 50px;
+ height: 50px;
+ border: solid 1px #2c3e50;
+ border-radius: 20px;
+ cursor: move;
+ position: absolute;
+}
+
+
\ No newline at end of file
--
GitLab