-
Notifications
You must be signed in to change notification settings - Fork 827
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(whiteboard): disable scale behavior, instead do scroll
- Loading branch information
Showing
6 changed files
with
106 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import type { AnimationMode, WindowManager } from "@netless/window-manager"; | ||
|
||
// Let mouse wheel act as scrolling the whiteboard | ||
export function mousewheelToScroll(root: HTMLElement, manager: WindowManager): () => void { | ||
const listener = (ev: Event): void => { | ||
ev.preventDefault(); | ||
ev.stopPropagation(); | ||
const dy = (ev as WheelEvent).deltaY || 0; | ||
manager.moveCamera({ | ||
centerY: manager.camera.centerY + dy * manager.camera.scale, | ||
animationMode: "immediately" as AnimationMode.Immediately, | ||
}); | ||
}; | ||
root.addEventListener("wheel", listener, true); | ||
return () => root.removeEventListener("wheel", listener, true); | ||
} |
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,16 @@ | ||
import type { AnimationMode, WindowManager } from "@netless/window-manager"; | ||
|
||
// Let mouse wheel act as scrolling the whiteboard | ||
export function mousewheelToScroll(root: HTMLElement, manager: WindowManager): () => void { | ||
const listener = (ev: Event): void => { | ||
ev.preventDefault(); | ||
ev.stopPropagation(); | ||
const dy = (ev as WheelEvent).deltaY || 0; | ||
manager.moveCamera({ | ||
centerY: manager.camera.centerY + dy * manager.camera.scale, | ||
animationMode: "immediately" as AnimationMode.Immediately, | ||
}); | ||
}; | ||
root.addEventListener("wheel", listener, true); | ||
return () => root.removeEventListener("wheel", listener, true); | ||
} |