Merge pull request #80 from avelican/main

fix scrolling on iOS and desktop
This commit is contained in:
SuperDev 2024-02-04 19:04:30 -06:00 committed by GitHub
commit 74cb1ac2ee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,13 +1,15 @@
import { ReactNode } from "react";
import { ReactNode, useRef, useEffect } from "react";
export function ScrollIntoView({ children }: { children: ReactNode }) {
// Scroll into view as soon as we appear
const myRef = useRef(null);
useEffect(() => {
myRef.current.scrollIntoView({ behavior: 'smooth' });
}, []);
return (
<div
ref={(node) => {
if (!node) return;
node.scrollIntoView({ behavior: "smooth" });
}}
>
<div ref={myRef}>
{children}
</div>
);