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;