From 4545864d5e60ea996128cf01ed74acefc0c8fb4b Mon Sep 17 00:00:00 2001 From: "nekomimi.pet" Date: Mon, 19 Oct 2026 23:54:30 -0400 Subject: [PATCH] web: name what makes an element scroll sideways The canvas's sideways-scroll test was one long conditional. Whether an element scrolls sideways is now its own small function, and the walk up the event path stops at each of its two limits on its own line. --- web/src/lib/Canvas.svelte | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/web/src/lib/Canvas.svelte b/web/src/lib/Canvas.svelte index 461478e8..eabfae04 100644 --- a/web/src/lib/Canvas.svelte +++ b/web/src/lib/Canvas.svelte @@ -41,13 +41,20 @@ function scrollsSideways(event: WheelEvent) { if (board.viewport.zoom < READABLE) return false; for (const target of event.composedPath()) { - if (!(target instanceof HTMLElement) || target.classList.contains('svelte-flow__node')) break; - const overflow = getComputedStyle(target).overflowX; - if ((overflow === 'auto' || overflow === 'scroll') && target.scrollWidth > target.clientWidth + 1) return true; + // Nothing outside the window under the pointer scrolls it. + if (!(target instanceof HTMLElement)) break; + if (target.classList.contains('svelte-flow__node')) break; + if (scrollable(target)) return true; } return false; } + const SCROLLING = new Set(['auto', 'scroll']); + function scrollable(element: HTMLElement) { + const overflowing = element.scrollWidth > element.clientWidth + 1; + return overflowing && SCROLLING.has(getComputedStyle(element).overflowX); + } + // A pinch moves a few pixels at a time, a mouse wheel's notch a hundred or // so (or a few lines), so a notch is one fixed step rather than a jump. const NOTCH = 1.1; -- knotmirror 0.0.1