mirror of
https://github.com/DefectingCat/DefectingCat.github.io
synced 2025-07-15 16:51:37 +00:00
add get mouse position function
This commit is contained in:
@ -85,3 +85,15 @@ export const generateToc = (source: string) => {
|
||||
|
||||
return toc;
|
||||
};
|
||||
|
||||
export const getMousePosition = (e: MouseEvent | globalThis.TouchEvent) => {
|
||||
return e instanceof MouseEvent
|
||||
? {
|
||||
x: e.clientX,
|
||||
y: e.clientY,
|
||||
}
|
||||
: {
|
||||
x: e.touches[0].clientX,
|
||||
y: e.touches[0].clientY,
|
||||
};
|
||||
};
|
||||
|
Reference in New Issue
Block a user