From efcc2e97beb8c3b05f422fe7efafa059447473de Mon Sep 17 00:00:00 2001
From: Ben Lin <maobin001@msn.com>
Date: 星期四, 01 八月 2024 17:23:58 +0800
Subject: [PATCH] 产品绑定工艺路线更新

---
 src/components/Scrollbar/src/bar.ts |   56 ++++++++++++++++++++++++++++++--------------------------
 1 files changed, 30 insertions(+), 26 deletions(-)

diff --git a/src/components/Scrollbar/src/bar.ts b/src/components/Scrollbar/src/bar.ts
index 64bd289..1a95059 100644
--- a/src/components/Scrollbar/src/bar.ts
+++ b/src/components/Scrollbar/src/bar.ts
@@ -8,13 +8,11 @@
   inject,
   Ref,
 } from 'vue';
-import { on, off } from '/@/utils/domUtils';
-
+import { on, off } from '@/utils/domUtils';
 import { renderThumbStyle, BAR_MAP } from './util';
 
 export default defineComponent({
   name: 'Bar',
-
   props: {
     vertical: Boolean,
     size: String,
@@ -30,6 +28,35 @@
     });
     const barStore = ref<Recordable>({});
     const cursorDown = ref();
+
+    const mouseMoveDocumentHandler = (e: any) => {
+      if (cursorDown.value === false) {
+        return;
+      }
+      const prevPage = barStore.value[bar.value.axis];
+
+      if (!prevPage) {
+        return;
+      }
+
+      const offset =
+        (instance?.vnode.el?.getBoundingClientRect()[bar.value.direction] - e[bar.value.client]) *
+        -1;
+      const thumbClickPosition = thumb.value[bar.value.offset] - prevPage;
+      const thumbPositionPercentage =
+        ((offset - thumbClickPosition) * 100) / instance?.vnode.el?.[bar.value.offset];
+      wrap.value[bar.value.scroll] =
+        (thumbPositionPercentage * wrap.value[bar.value.scrollSize]) / 100;
+    };
+
+    const startDrag = (e: any) => {
+      e.stopImmediatePropagation();
+      cursorDown.value = true;
+      on(document, 'mousemove', mouseMoveDocumentHandler);
+      on(document, 'mouseup', mouseUpDocumentHandler);
+      document.onselectstart = () => false;
+    };
+
     const clickThumbHandler = (e: any) => {
       // prevent click event of right button
       if (e.ctrlKey || e.button === 2) {
@@ -50,29 +77,6 @@
       const thumbPositionPercentage =
         ((offset - thumbHalf) * 100) / instance?.vnode.el?.[bar.value.offset];
 
-      wrap.value[bar.value.scroll] =
-        (thumbPositionPercentage * wrap.value[bar.value.scrollSize]) / 100;
-    };
-    const startDrag = (e: any) => {
-      e.stopImmediatePropagation();
-      cursorDown.value = true;
-      on(document, 'mousemove', mouseMoveDocumentHandler);
-      on(document, 'mouseup', mouseUpDocumentHandler);
-      document.onselectstart = () => false;
-    };
-
-    const mouseMoveDocumentHandler = (e: any) => {
-      if (cursorDown.value === false) return;
-      const prevPage = barStore.value[bar.value.axis];
-
-      if (!prevPage) return;
-
-      const offset =
-        (instance?.vnode.el?.getBoundingClientRect()[bar.value.direction] - e[bar.value.client]) *
-        -1;
-      const thumbClickPosition = thumb.value[bar.value.offset] - prevPage;
-      const thumbPositionPercentage =
-        ((offset - thumbClickPosition) * 100) / instance?.vnode.el?.[bar.value.offset];
       wrap.value[bar.value.scroll] =
         (thumbPositionPercentage * wrap.value[bar.value.scrollSize]) / 100;
     };

--
Gitblit v1.9.3