fix: keep bottom line on tile grids that have content below

This commit is contained in:
LukeGus committed 2026-11-05 16:47:37 -06:00
1 parent 528092846c
commit c28cda7822
1 file changed
+5 -2
+5 -2
View File
@@ -42,17 +42,20 @@ function useReachesBottom(ref: React.RefObject<HTMLElement | null>) {
if (!element || !scroller) return; if (!element || !scroller) return;
// Measured without the line itself, so showing it never flips the answer. // Measured without the line itself, so showing it never flips the answer.
const update = () => { const update = () => {
const line = reachesRef.current ? 0 : 1;
const end = const end =
element.getBoundingClientRect().bottom - element.getBoundingClientRect().bottom -
scroller.getBoundingClientRect().top + scroller.getBoundingClientRect().top +
scroller.scrollTop - scroller.scrollTop -
(reachesRef.current ? 0 : 1); line;
setReaches(end >= scroller.clientHeight - 0.5); // Compared with the whole scrollable height, so content below keeps the line.
setReaches(end >= scroller.scrollHeight - line - 0.5);
}; };
update(); update();
const observer = new ResizeObserver(update); const observer = new ResizeObserver(update);
observer.observe(scroller); observer.observe(scroller);
observer.observe(element); observer.observe(element);
for (const child of Array.from(scroller.children)) observer.observe(child);
return () => observer.disconnect(); return () => observer.disconnect();
}, [ref]); }, [ref]);
return reaches; return reaches;