Merge branch 'main' into web-layout

This commit is contained in:
Dan Abramov
2024-01-11 22:47:17 +00:00
245 changed files with 21884 additions and 4478 deletions
+2 -14
View File
@@ -109,7 +109,7 @@ function ListImpl<ItemT>(
const containerRef = useRef(null)
useResizeObserver(containerRef, onContentSizeChange)
// --- onScroll & onScrollEndWeb ---
// --- onScroll ---
const [isInsideVisibleTree, setIsInsideVisibleTree] = React.useState(false)
const handleWindowScroll = useNonReactiveCallback(() => {
if (isInsideVisibleTree) {
@@ -124,16 +124,6 @@ function ListImpl<ItemT>(
)
}
})
const handleWindowScrollEnd = useNonReactiveCallback(() => {
if (isInsideVisibleTree) {
contextScrollHandlers.onScrollEndWeb?.({
contentOffset: {
x: Math.max(0, window.scrollX),
y: Math.max(0, window.scrollY),
},
})
}
})
React.useEffect(() => {
if (!isInsideVisibleTree) {
// Prevents hidden tabs from firing scroll events.
@@ -141,12 +131,10 @@ function ListImpl<ItemT>(
return
}
window.addEventListener('scroll', handleWindowScroll)
window.addEventListener('scrollend', handleWindowScrollEnd)
return () => {
window.removeEventListener('scroll', handleWindowScroll)
window.removeEventListener('scrollend', handleWindowScrollEnd)
}
}, [isInsideVisibleTree, handleWindowScroll, handleWindowScrollEnd])
}, [isInsideVisibleTree, handleWindowScroll])
// --- onScrolledDownChange ---
const isScrolledDown = useRef(false)