-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
performance(editor) Combined mouse up handling (#6416)
- `useSelectOrLiveModeSelectAndHover` now calls the "global" `handleMouseUp` function that gathers actions from potentially multiple functions. - `EditorCanvas` now hands off it's mouse up handling via the `addMouseUpHandler` utility function.
- Loading branch information
1 parent
9bb6536
commit 167ff05
Showing
4 changed files
with
84 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import type { EditorAction } from '../components/editor/action-types' | ||
|
||
export type MouseHandler = (event: MouseEvent) => Array<EditorAction> | ||
|
||
let mouseUpHandlers: Array<MouseHandler> = [] | ||
|
||
export function addMouseUpHandler(handler: MouseHandler): void { | ||
mouseUpHandlers.push(handler) | ||
} | ||
|
||
export function removeMouseUpHandler(handler: MouseHandler): void { | ||
mouseUpHandlers = mouseUpHandlers.filter((mouseUpHandler) => mouseUpHandler !== handler) | ||
} | ||
|
||
export function handleGlobalMouseUp(event: MouseEvent): Array<EditorAction> { | ||
let result: Array<EditorAction> = [] | ||
for (const handler of mouseUpHandlers) { | ||
result.push(...handler(event)) | ||
} | ||
return result | ||
} |