Skip to content

Commit 3724d27

Browse files
committedSep 1, 2023
🎨 fix #9089
1 parent 493eba5 commit 3724d27

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed
 

‎app/src/boot/globalEvent/event.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {windowKeyUp} from "./keyup";
55
import {windowKeyDown} from "./keydown";
66
import {globalClick} from "./click";
77
import {goBack, goForward} from "../../util/backForward";
8+
import {Constants} from "../../constants";
89

910
export const initWindowEvent = (app: App) => {
1011
document.body.addEventListener("mouseleave", () => {
@@ -14,9 +15,18 @@ export const initWindowEvent = (app: App) => {
1415
window.siyuan.layout.bottomDock.hideDock();
1516
}
1617
});
18+
let mouseIsEnter = false;
19+
document.body.addEventListener("mouseenter", () => {
20+
if (window.siyuan.layout.leftDock) {
21+
mouseIsEnter = true;
22+
setTimeout(() => {
23+
mouseIsEnter = false;
24+
}, Constants.TIMEOUT_TRANSITION);
25+
}
26+
});
1727

1828
window.addEventListener("mousemove", (event: MouseEvent & { target: HTMLElement }) => {
19-
windowMouseMove(event);
29+
windowMouseMove(event, mouseIsEnter);
2030
});
2131

2232
window.addEventListener("mouseup", (event) => {
@@ -46,6 +56,6 @@ export const initWindowEvent = (app: App) => {
4656
});
4757

4858
window.addEventListener("click", (event: MouseEvent & { target: HTMLElement }) => {
49-
globalClick(event);
59+
globalClick(event);
5060
});
5161
};

‎app/src/boot/globalEvent/mousemove.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ const getRightBlock = (element: HTMLElement, x: number, y: number) => {
1414
return nodeElement;
1515
};
1616

17-
export const windowMouseMove = (event: MouseEvent & { target: HTMLElement }) => {
17+
export const windowMouseMove = (event: MouseEvent & { target: HTMLElement }, mouseIsEnter:boolean) => {
18+
if (document.body.classList.contains("body--blur")) {
19+
// 非激活状态下不执行 https://ld246.com/article/1693474547631
20+
return;
21+
}
1822
// https://github.com/siyuan-note/siyuan/pull/8793
1923
const coordinates = window.siyuan.coordinates ?? (window.siyuan.coordinates = {
2024
pageX: 0,
@@ -40,7 +44,8 @@ export const windowMouseMove = (event: MouseEvent & { target: HTMLElement }) =>
4044
item.editor.protyle.breadcrumb.render(item.editor.protyle, true);
4145
});
4246
}
43-
if (event.buttons === 0 && // 鼠标按键被按下时不触发
47+
if (!mouseIsEnter &&
48+
event.buttons === 0 && // 鼠标按键被按下时不触发
4449
window.siyuan.layout.bottomDock &&
4550
!isWindow() && !hasClosestByClassName(event.target, "b3-dialog") && !hasClosestByClassName(event.target, "b3-menu")) {
4651
if (event.clientX < 43) {

0 commit comments

Comments
 (0)
Please sign in to comment.