Checkpoint: sort change scrolling fixed
This commit is contained in:
@@ -110,16 +110,19 @@ export function Inner({uri}: {uri: string | undefined}) {
|
|||||||
* handler scrolls the `List` to the top of the highlighted post after
|
* handler scrolls the `List` to the top of the highlighted post after
|
||||||
* parents are prepended, offset by any fixed elements like the header.
|
* parents are prepended, offset by any fixed elements like the header.
|
||||||
*/
|
*/
|
||||||
const hasScrolledToAnchor = useRef(false)
|
{
|
||||||
|
/* const hasScrolledToAnchor = useRef(false) */
|
||||||
|
}
|
||||||
const onContentSizeChangeWebOnly = web(() => {
|
const onContentSizeChangeWebOnly = web(() => {
|
||||||
const anchorElement = anchorRef.current as any as Element
|
const anchorElement = anchorRef.current as any as Element
|
||||||
const headerElement = headerRef.current as any as Element
|
const headerElement = headerRef.current as any as Element
|
||||||
if (
|
if (
|
||||||
anchorElement &&
|
anchorElement &&
|
||||||
headerElement &&
|
headerElement &&
|
||||||
!deferParents &&
|
!deferParents
|
||||||
!hasScrolledToAnchor.current
|
//!hasScrolledToAnchor.current
|
||||||
) {
|
) {
|
||||||
|
console.log('HANDLE')
|
||||||
// distance from top of the list (screen)
|
// distance from top of the list (screen)
|
||||||
const anchorOffsetTop = anchorElement.getBoundingClientRect().top
|
const anchorOffsetTop = anchorElement.getBoundingClientRect().top
|
||||||
const headerHeight = headerElement.getBoundingClientRect().height
|
const headerHeight = headerElement.getBoundingClientRect().height
|
||||||
@@ -131,11 +134,20 @@ export function Inner({uri}: {uri: string | undefined}) {
|
|||||||
* at all.
|
* at all.
|
||||||
*/
|
*/
|
||||||
if (scrollPosition >= headerHeight) {
|
if (scrollPosition >= headerHeight) {
|
||||||
|
console.log('Scrolling to anchor post at', scrollPosition)
|
||||||
listRef.current?.scrollToOffset({
|
listRef.current?.scrollToOffset({
|
||||||
animated: false,
|
animated: false,
|
||||||
offset: scrollPosition,
|
offset: scrollPosition,
|
||||||
})
|
})
|
||||||
hasScrolledToAnchor.current = true
|
{
|
||||||
|
/* hasScrolledToAnchor.current = true */
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.log('Scrolling to first position')
|
||||||
|
listRef.current?.scrollToOffset({
|
||||||
|
animated: false,
|
||||||
|
offset: headerHeight * -1,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user