Add global mouse position variable (#8793)

* 🎨 add global mouse position variable

* 🎨 add global mouse position variables

* 🎨 add global mouse position variable `coordinates`

* 🎨 Increase operating efficiency

* 🎨 Increase operating efficiency
This commit is contained in:
Yingyi / 颖逸 2023-07-21 10:39:54 +08:00 committed by GitHub
parent 9a383130f0
commit 4f812bcf0c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 0 deletions

View file

@ -106,6 +106,22 @@ export const globalShortcut = (app: App) => {
}
});
window.addEventListener("mousemove", (event: MouseEvent & { target: HTMLElement }) => {
// https://github.com/siyuan-note/siyuan/pull/8793
const coordinates = window.siyuan.coordinates ?? (window.siyuan.coordinates = {
pageX: 0,
pageY: 0,
clientX: 0,
clientY: 0,
screenX: 0,
screenY: 0,
});
coordinates.pageX = event.pageX;
coordinates.pageY = event.pageY;
coordinates.clientX = event.clientX;
coordinates.clientY = event.clientY;
coordinates.screenX = event.screenX;
coordinates.screenY = event.screenY;
if (window.siyuan.hideBreadcrumb) {
document.querySelectorAll(".protyle-breadcrumb__bar--hide").forEach(item => {
item.classList.remove("protyle-breadcrumb__bar--hide");

View file

@ -280,6 +280,14 @@ interface ISiyuan {
ctrlIsPressed?: boolean,
altIsPressed?: boolean,
shiftIsPressed?: boolean,
coordinates?: {
pageX: number,
pageY: number,
clientX: number,
clientY: number,
screenX: number,
screenY: number,
},
menus?: import("../menus").Menus
languages?: {
[key: string]: any;