drop onreveal
This commit is contained in:
parent
dc064d414f
commit
02436c6aaf
|
|
@ -133,12 +133,11 @@ export function useAnchor(id: AnchorID, onReveal: () => void) {
|
||||||
}, [id, onReveal]);
|
}, [id, onReveal]);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Anchor({ id, onReveal, children }: React.PropsWithChildren<{ id: AnchorID, onReveal?(): void }>) {
|
export function Anchor({ id, children }: React.PropsWithChildren<{ id: AnchorID }>) {
|
||||||
const ref = React.useRef<HTMLDivElement>(null);
|
const ref = React.useRef<HTMLDivElement>(null);
|
||||||
const onAnchorReveal = React.useCallback(() => {
|
const onAnchorReveal = React.useCallback(() => {
|
||||||
onReveal?.();
|
|
||||||
requestAnimationFrame(() => ref.current?.scrollIntoView({ block: 'start', inline: 'start' }));
|
requestAnimationFrame(() => ref.current?.scrollIntoView({ block: 'start', inline: 'start' }));
|
||||||
}, [onReveal]);
|
}, []);
|
||||||
useAnchor(id, onAnchorReveal);
|
useAnchor(id, onAnchorReveal);
|
||||||
|
|
||||||
return <div ref={ref}>{children}</div>;
|
return <div ref={ref}>{children}</div>;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue