mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
fix: cursor being leaked outside of canvas (#3161)
This commit is contained in:
parent
f295ba98c5
commit
c77c9ce65a
8 changed files with 69 additions and 52 deletions
24
src/utils.ts
24
src/utils.ts
|
@ -160,15 +160,29 @@ export const removeSelection = () => {
|
|||
|
||||
export const distance = (x: number, y: number) => Math.abs(x - y);
|
||||
|
||||
export const resetCursor = () => {
|
||||
document.documentElement.style.cursor = "";
|
||||
export const resetCursor = (canvas: HTMLCanvasElement | null) => {
|
||||
if (canvas) {
|
||||
canvas.style.cursor = "";
|
||||
}
|
||||
};
|
||||
|
||||
export const setCursorForShape = (shape: string) => {
|
||||
export const setCursor = (canvas: HTMLCanvasElement | null, cursor: string) => {
|
||||
if (canvas) {
|
||||
canvas.style.cursor = cursor;
|
||||
}
|
||||
};
|
||||
|
||||
export const setCursorForShape = (
|
||||
canvas: HTMLCanvasElement | null,
|
||||
shape: string,
|
||||
) => {
|
||||
if (!canvas) {
|
||||
return;
|
||||
}
|
||||
if (shape === "selection") {
|
||||
resetCursor();
|
||||
resetCursor(canvas);
|
||||
} else {
|
||||
document.documentElement.style.cursor = CURSOR_TYPE.CROSSHAIR;
|
||||
canvas.style.cursor = CURSOR_TYPE.CROSSHAIR;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue