Checkpoint: sort change scrolling fixed

This commit is contained in:
Eric Bailey
2025-06-05 13:56:58 -05:00
parent cdff302bbe
commit 6c582cceb4
+16 -4
View File
@@ -110,16 +110,19 @@ export function Inner({uri}: {uri: string | undefined}) {
* handler scrolls the `List` to the top of the highlighted post after
* parents are prepended, offset by any fixed elements like the header.
*/
const hasScrolledToAnchor = useRef(false)
{
/* const hasScrolledToAnchor = useRef(false) */
}
const onContentSizeChangeWebOnly = web(() => {
const anchorElement = anchorRef.current as any as Element
const headerElement = headerRef.current as any as Element
if (
anchorElement &&
headerElement &&
!deferParents &&
!hasScrolledToAnchor.current
!deferParents
//!hasScrolledToAnchor.current
) {
console.log('HANDLE')
// distance from top of the list (screen)
const anchorOffsetTop = anchorElement.getBoundingClientRect().top
const headerHeight = headerElement.getBoundingClientRect().height
@@ -131,11 +134,20 @@ export function Inner({uri}: {uri: string | undefined}) {
* at all.
*/
if (scrollPosition >= headerHeight) {
console.log('Scrolling to anchor post at', scrollPosition)
listRef.current?.scrollToOffset({
animated: false,
offset: scrollPosition,
})
hasScrolledToAnchor.current = true
{
/* hasScrolledToAnchor.current = true */
}
} else {
console.log('Scrolling to first position')
listRef.current?.scrollToOffset({
animated: false,
offset: headerHeight * -1,
})
}
}
})