UNPKG

@1771technologies/lytenyte-pro

Version:

Blazingly fast headless React data grid with 100s of features.

24 lines (23 loc) 832 B
import { jsx as _jsx } from "react/jsx-runtime"; import { useEffect, useState } from "react"; import { useTreeRoot } from "../context.js"; export function ForceSyncScrolling(props) { const [scroll, setScroll] = useState(0); const ctx = useTreeRoot(); useEffect(() => { if (!ctx.panel) return; const controller = new AbortController(); ctx.panel.addEventListener("scroll", () => { setScroll(Math.max(0, ctx.panel.scrollTop)); }, { signal: controller.signal }); return () => controller.abort(); }, [ctx.panel]); return (_jsx("div", { style: { position: "sticky", top: 0, height: 0, width: "100%", transform: `translate3d(0px, -${scroll}px, 0px)`, }, children: props.children })); }