mirror of
https://github.com/docmost/docmost.git
synced 2026-08-31 10:55:29 +08:00
feat(base): make column headers sticky in standalone and inline contexts
Split the unified .gridWrapper into a sticky band (containing column headers, plus banner + toolbar in inline) and a body grid that owns horizontal scroll. The band's vertical sticky anchor is automatic CSS: the table's scrollport in standalone, the page in inline. A small useHorizontalScrollSync hook mirrors body scrollLeft onto the header and turns wheel-on-header into pan-on-body.
This commit is contained in:
@@ -42,11 +42,16 @@ export function useHorizontalScrollSync<
|
||||
// scrollLeft. Convert vertical wheel ticks into horizontal pan.
|
||||
if (Math.abs(e.deltaX) > Math.abs(e.deltaY)) return;
|
||||
if (e.deltaY === 0) return;
|
||||
// Suppress the browser's default vertical scroll on the page
|
||||
// (or the standalone scrollport) — we're consuming this wheel
|
||||
// event as a horizontal pan, not a vertical scroll. Requires a
|
||||
// non-passive listener (configured below).
|
||||
e.preventDefault();
|
||||
body.scrollLeft += e.deltaY;
|
||||
};
|
||||
|
||||
body.addEventListener("scroll", onBodyScroll, { passive: true });
|
||||
header.addEventListener("wheel", onHeaderWheel, { passive: true });
|
||||
header.addEventListener("wheel", onHeaderWheel, { passive: false });
|
||||
|
||||
// Initial sync — covers the case where body is already scrolled
|
||||
// when the hook mounts (e.g. after a route change).
|
||||
|
||||
Reference in New Issue
Block a user