feat: initial persistence (#3)

This commit is contained in:
Kirjava
2024-07-25 14:03:38 +01:00
committed by GitHub
parent 2b1bf0fdaf
commit 5db834e2f7
9 changed files with 249 additions and 51 deletions

View File

@@ -9,15 +9,13 @@ export function useSnapScroll() {
const messageRef = useCallback((node: HTMLDivElement | null) => {
if (node) {
const observer = new ResizeObserver(() => {
if (autoScrollRef.current) {
if (scrollNodeRef.current) {
const { scrollHeight, clientHeight } = scrollNodeRef.current;
const scrollTarget = scrollHeight - clientHeight;
if (autoScrollRef.current && scrollNodeRef.current) {
const { scrollHeight, clientHeight } = scrollNodeRef.current;
const scrollTarget = scrollHeight - clientHeight;
scrollNodeRef.current.scrollTo({
top: scrollTarget,
});
}
scrollNodeRef.current.scrollTo({
top: scrollTarget,
});
}
});