瀏覽代碼

:bug: https://github.com/siyuan-note/siyuan/issues/5675 3

Vanessa 2 年之前
父節點
當前提交
e91ae262ec
共有 1 個文件被更改,包括 29 次插入25 次删除
  1. 29 25
      app/src/protyle/toolbar/index.ts

+ 29 - 25
app/src/protyle/toolbar/index.ts

@@ -715,6 +715,8 @@ export class Toolbar {
                         pingElement.classList.add("block__icon--active");
                         pingElement.setAttribute("aria-label", window.siyuan.languages.unpin);
                     }
+                    event.preventDefault()
+                    event.stopPropagation();
                 }
                 return;
             }
@@ -772,32 +774,34 @@ export class Toolbar {
             dragBgElement.classList.remove("fn__none");
             const x = event.clientX - parseInt(this.subElement.style.left);
             const y = event.clientY - parseInt(this.subElement.style.top);
-            setTimeout(() => {
-                // windows 需等待 dragBgElement 显示后才可以进行 move https://github.com/siyuan-note/siyuan/issues/2950
-                documentSelf.onmousemove = (moveEvent: MouseEvent) => {
-                    let positionX = moveEvent.clientX - x;
-                    let positionY = moveEvent.clientY - y;
-                    if (positionX > window.innerWidth - this.subElement.clientWidth) {
-                        positionX = window.innerWidth - this.subElement.clientWidth;
-                    }
-                    if (positionY > window.innerHeight - this.subElement.clientHeight) {
-                        positionY = window.innerHeight - this.subElement.clientHeight;
-                    }
-                    this.subElement.style.left = Math.max(positionX, 0) + "px";
-                    this.subElement.style.top = Math.max(positionY, Constants.SIZE_TOOLBAR_HEIGHT) + "px";
-                    this.subElement.firstElementChild.setAttribute("data-drag", "true");
-                };
+            // setTimeout(() => {
+            // windows 需等待 dragBgElement 显示后才可以进行 move https://github.com/siyuan-note/siyuan/issues/2950
+            documentSelf.onmousemove = (moveEvent: MouseEvent) => {
+                let positionX = moveEvent.clientX - x;
+                let positionY = moveEvent.clientY - y;
+                if (positionX > window.innerWidth - this.subElement.clientWidth) {
+                    positionX = window.innerWidth - this.subElement.clientWidth;
+                }
+                if (positionY > window.innerHeight - this.subElement.clientHeight) {
+                    positionY = window.innerHeight - this.subElement.clientHeight;
+                }
+                this.subElement.style.left = Math.max(positionX, 0) + "px";
+                this.subElement.style.top = Math.max(positionY, Constants.SIZE_TOOLBAR_HEIGHT) + "px";
+                this.subElement.firstElementChild.setAttribute("data-drag", "true");
+            };
+            // });
+            console.log("onmousedown");
+            documentSelf.onmouseup = () => {
+                console.log("onmouseup");
+                this.subElement.style.userSelect = "auto";
+                documentSelf.onmousemove = null;
+                documentSelf.onmouseup = null;
+                documentSelf.ondragstart = null;
+                documentSelf.onselectstart = null;
+                documentSelf.onselect = null;
+                dragBgElement.classList.add("fn__none");
+            };
 
-                documentSelf.onmouseup = () => {
-                    this.subElement.style.userSelect = "auto";
-                    documentSelf.onmousemove = null;
-                    documentSelf.onmouseup = null;
-                    documentSelf.ondragstart = null;
-                    documentSelf.onselectstart = null;
-                    documentSelf.onselect = null;
-                    dragBgElement.classList.add("fn__none");
-                };
-            });
             return;
         });
         const textElement = this.subElement.querySelector(".b3-text-field") as HTMLTextAreaElement;