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:
りき萌 2025-06-26 18:53:17 +02:00
parent a40480a464
commit b4acab2c9c

View file

@ -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(