From d0c596f3ba859b3cfa16b9b0c890bb0cd3c7c824 Mon Sep 17 00:00:00 2001 From: Yihui Liao <44729383+yihuiliao@users.noreply.github.com> Date: Thu, 25 Sep 2025 10:12:06 -0700 Subject: [PATCH] revert: use timeout to determine scroll end --- .../virtualizer/src/ScrollView.tsx | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/packages/@react-aria/virtualizer/src/ScrollView.tsx b/packages/@react-aria/virtualizer/src/ScrollView.tsx index e89d2f2df1c..7c4988a5b3e 100644 --- a/packages/@react-aria/virtualizer/src/ScrollView.tsx +++ b/packages/@react-aria/virtualizer/src/ScrollView.tsx @@ -86,15 +86,6 @@ export function useScrollView(props: ScrollViewProps, ref: RefObject { - state.isScrolling = false; - setScrolling(false); - state.scrollTimeout = null; - - window.dispatchEvent(new Event('tk.connect-observer')); - onScrollEnd?.(); - }, [state, onScrollEnd]); - let onScroll = useCallback((e) => { if (e.target !== e.currentTarget) { return; @@ -128,21 +119,29 @@ export function useScrollView(props: ScrollViewProps, ref: RefObject { + state.isScrolling = false; + setScrolling(false); + state.scrollTimeout = null; + + window.dispatchEvent(new Event('tk.connect-observer')); + if (onScrollEnd) { + onScrollEnd(); + } + }, 300); } }); - }, [props, direction, state, contentSize, onVisibleRectChange, onScrollStart, onScrollTimeout]); + }, [props, direction, state, contentSize, onVisibleRectChange, onScrollStart, onScrollEnd]); // Attach event directly to ref so RAC Virtualizer doesn't need to send props upward. useEvent(ref, 'scroll', onScroll); - useEvent(ref, 'scrollend', onScrollTimeout); useEffect(() => { return () => {