fix jank when moving the mouse cursor outside the canvas
mouse events are now consistently sourced from the window, so if you try to draw and move your mouse over the panel, it won't glitch out
This commit is contained in:
parent
a40480a464
commit
b4acab2c9c
1 changed files with 3 additions and 6 deletions
|
@ -451,10 +451,10 @@ class CanvasRenderer extends HTMLElement {
|
|||
|
||||
async #cursorReportingBehaviour() {
|
||||
while (true) {
|
||||
let event = await listen([this, "mousemove"]);
|
||||
let event = await listen([window, "mousemove"]);
|
||||
let [x, y] = this.viewport.toViewportSpace(
|
||||
event.clientX - this.clientLeft,
|
||||
event.offsetY - this.clientTop,
|
||||
event.clientY - this.clientTop,
|
||||
this.getWindowSize(),
|
||||
);
|
||||
this.dispatchEvent(Object.assign(new Event(".cursor"), { x, y }));
|
||||
|
@ -493,10 +493,7 @@ class InteractEvent extends Event {
|
|||
|
||||
continueAsDotter() {
|
||||
(async () => {
|
||||
let event = await listen(
|
||||
[this.canvasRenderer, "mousemove"],
|
||||
[this.canvasRenderer, "mouseup"],
|
||||
);
|
||||
let event = await listen([window, "mousemove"], [window, "mouseup"]);
|
||||
|
||||
if (event.type == "mousemove") {
|
||||
let [mouseX, mouseY] = this.canvasRenderer.viewport.toViewportSpace(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue