@react-native-ohos/flash-list 1.8.3 → 2.1.1-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.OpenSource +1 -1
- package/dist/AnimatedFlashList.d.ts +4 -28
- package/dist/AnimatedFlashList.d.ts.map +1 -1
- package/dist/AnimatedFlashList.js +5 -30
- package/dist/AnimatedFlashList.js.map +1 -1
- package/dist/FlashList.d.ts +1 -179
- package/dist/FlashList.d.ts.map +1 -1
- package/dist/FlashList.js +1 -599
- package/dist/FlashList.js.map +1 -1
- package/dist/FlashListProps.d.ts +285 -278
- package/dist/FlashListProps.d.ts.map +1 -1
- package/dist/FlashListProps.js +5 -31
- package/dist/FlashListProps.js.map +1 -1
- package/dist/FlashListRef.d.ts +305 -0
- package/dist/FlashListRef.d.ts.map +1 -0
- package/dist/FlashListRef.js +2 -0
- package/dist/FlashListRef.js.map +1 -0
- package/dist/benchmark/AutoScrollHelper.d.ts +17 -40
- package/dist/benchmark/AutoScrollHelper.d.ts.map +1 -1
- package/dist/benchmark/AutoScrollHelper.js +59 -90
- package/dist/benchmark/AutoScrollHelper.js.map +1 -1
- package/dist/benchmark/JSFPSMonitor.d.ts +22 -45
- package/dist/benchmark/JSFPSMonitor.d.ts.map +1 -1
- package/dist/benchmark/JSFPSMonitor.js +59 -87
- package/dist/benchmark/JSFPSMonitor.js.map +1 -1
- package/dist/benchmark/roundToDecimalPlaces.d.ts +1 -24
- package/dist/benchmark/roundToDecimalPlaces.d.ts.map +1 -1
- package/dist/benchmark/roundToDecimalPlaces.js +4 -31
- package/dist/benchmark/roundToDecimalPlaces.js.map +1 -1
- package/dist/benchmark/useBenchmark.d.ts +40 -57
- package/dist/benchmark/useBenchmark.d.ts.map +1 -1
- package/dist/benchmark/useBenchmark.js +119 -189
- package/dist/benchmark/useBenchmark.js.map +1 -1
- package/dist/benchmark/useDataMultiplier.d.ts +8 -31
- package/dist/benchmark/useDataMultiplier.d.ts.map +1 -1
- package/dist/benchmark/useDataMultiplier.js +19 -47
- package/dist/benchmark/useDataMultiplier.js.map +1 -1
- package/dist/benchmark/useFlatListBenchmark.d.ts +14 -35
- package/dist/benchmark/useFlatListBenchmark.d.ts.map +1 -1
- package/dist/benchmark/useFlatListBenchmark.js +92 -122
- package/dist/benchmark/useFlatListBenchmark.js.map +1 -1
- package/dist/errors/ErrorMessages.d.ts +16 -0
- package/dist/errors/ErrorMessages.d.ts.map +1 -0
- package/dist/errors/ErrorMessages.js +16 -0
- package/dist/errors/ErrorMessages.js.map +1 -0
- package/dist/errors/WarningMessages.d.ts +6 -0
- package/dist/errors/WarningMessages.d.ts.map +1 -0
- package/dist/errors/WarningMessages.js +7 -0
- package/dist/errors/WarningMessages.js.map +1 -0
- package/dist/index.d.ts +15 -36
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -54
- package/dist/index.js.map +1 -1
- package/dist/isNewArch.d.ts +2 -0
- package/dist/isNewArch.d.ts.map +1 -0
- package/dist/isNewArch.js +22 -0
- package/dist/isNewArch.js.map +1 -0
- package/dist/native/config/PlatformHelper.android.d.ts +6 -48
- package/dist/native/config/PlatformHelper.android.d.ts.map +1 -1
- package/dist/native/config/PlatformHelper.android.js +6 -45
- package/dist/native/config/PlatformHelper.android.js.map +1 -1
- package/dist/native/config/PlatformHelper.d.ts +6 -48
- package/dist/native/config/PlatformHelper.d.ts.map +1 -1
- package/dist/native/config/PlatformHelper.harmony.d.ts +29 -48
- package/dist/native/config/PlatformHelper.harmony.d.ts.map +1 -1
- package/dist/native/config/PlatformHelper.harmony.js +29 -44
- package/dist/native/config/PlatformHelper.harmony.js.map +1 -1
- package/dist/native/config/PlatformHelper.ios.d.ts +6 -48
- package/dist/native/config/PlatformHelper.ios.d.ts.map +1 -1
- package/dist/native/config/PlatformHelper.ios.js +6 -44
- package/dist/native/config/PlatformHelper.ios.js.map +1 -1
- package/dist/native/config/PlatformHelper.js +6 -45
- package/dist/native/config/PlatformHelper.js.map +1 -1
- package/dist/native/config/PlatformHelper.web.d.ts +6 -49
- package/dist/native/config/PlatformHelper.web.d.ts.map +1 -1
- package/dist/native/config/PlatformHelper.web.js +6 -47
- package/dist/native/config/PlatformHelper.web.js.map +1 -1
- package/dist/recyclerview/LayoutCommitObserver.d.ts +12 -0
- package/dist/recyclerview/LayoutCommitObserver.d.ts.map +1 -0
- package/dist/recyclerview/LayoutCommitObserver.js +58 -0
- package/dist/recyclerview/LayoutCommitObserver.js.map +1 -0
- package/dist/recyclerview/RecyclerView.d.ts +13 -0
- package/dist/recyclerview/RecyclerView.d.ts.map +1 -0
- package/dist/recyclerview/RecyclerView.js +368 -0
- package/dist/recyclerview/RecyclerView.js.map +1 -0
- package/dist/recyclerview/RecyclerViewContextProvider.d.ts +46 -0
- package/dist/recyclerview/RecyclerViewContextProvider.d.ts.map +1 -0
- package/dist/recyclerview/RecyclerViewContextProvider.js +10 -0
- package/dist/recyclerview/RecyclerViewContextProvider.js.map +1 -0
- package/dist/recyclerview/RecyclerViewManager.d.ts +78 -0
- package/dist/recyclerview/RecyclerViewManager.d.ts.map +1 -0
- package/dist/recyclerview/RecyclerViewManager.js +343 -0
- package/dist/recyclerview/RecyclerViewManager.js.map +1 -0
- package/dist/recyclerview/RecyclerViewProps.d.ts +2 -0
- package/dist/recyclerview/RecyclerViewProps.d.ts.map +1 -0
- package/dist/recyclerview/RecyclerViewProps.js +2 -0
- package/dist/recyclerview/RecyclerViewProps.js.map +1 -0
- package/dist/recyclerview/RenderStackManager.d.ts +86 -0
- package/dist/recyclerview/RenderStackManager.d.ts.map +1 -0
- package/dist/recyclerview/RenderStackManager.js +252 -0
- package/dist/recyclerview/RenderStackManager.js.map +1 -0
- package/dist/recyclerview/ViewHolder.d.ts +45 -0
- package/dist/recyclerview/ViewHolder.d.ts.map +1 -0
- package/dist/recyclerview/ViewHolder.js +94 -0
- package/dist/recyclerview/ViewHolder.js.map +1 -0
- package/dist/recyclerview/ViewHolderCollection.d.ts +63 -0
- package/dist/recyclerview/ViewHolderCollection.d.ts.map +1 -0
- package/dist/recyclerview/ViewHolderCollection.js +87 -0
- package/dist/recyclerview/ViewHolderCollection.js.map +1 -0
- package/dist/recyclerview/components/CompatScroller.d.ts +7 -0
- package/dist/recyclerview/components/CompatScroller.d.ts.map +1 -0
- package/dist/recyclerview/components/CompatScroller.js +7 -0
- package/dist/recyclerview/components/CompatScroller.js.map +1 -0
- package/dist/recyclerview/components/CompatView.d.ts +7 -0
- package/dist/recyclerview/components/CompatView.d.ts.map +1 -0
- package/dist/recyclerview/components/CompatView.js +7 -0
- package/dist/recyclerview/components/CompatView.js.map +1 -0
- package/dist/recyclerview/components/ScrollAnchor.d.ts +29 -0
- package/dist/recyclerview/components/ScrollAnchor.d.ts.map +1 -0
- package/dist/recyclerview/components/ScrollAnchor.js +33 -0
- package/dist/recyclerview/components/ScrollAnchor.js.map +1 -0
- package/dist/recyclerview/components/StickyHeaders.d.ts +38 -0
- package/dist/recyclerview/components/StickyHeaders.d.ts.map +1 -0
- package/dist/recyclerview/components/StickyHeaders.js +112 -0
- package/dist/recyclerview/components/StickyHeaders.js.map +1 -0
- package/dist/recyclerview/helpers/ConsecutiveNumbers.d.ts +51 -0
- package/dist/recyclerview/helpers/ConsecutiveNumbers.d.ts.map +1 -0
- package/dist/recyclerview/helpers/ConsecutiveNumbers.js +95 -0
- package/dist/recyclerview/helpers/ConsecutiveNumbers.js.map +1 -0
- package/dist/recyclerview/helpers/EngagedIndicesTracker.d.ts +105 -0
- package/dist/recyclerview/helpers/EngagedIndicesTracker.d.ts.map +1 -0
- package/dist/recyclerview/helpers/EngagedIndicesTracker.js +202 -0
- package/dist/recyclerview/helpers/EngagedIndicesTracker.js.map +1 -0
- package/dist/recyclerview/helpers/RenderTimeTracker.d.ts +14 -0
- package/dist/recyclerview/helpers/RenderTimeTracker.d.ts.map +1 -0
- package/dist/recyclerview/helpers/RenderTimeTracker.js +44 -0
- package/dist/recyclerview/helpers/RenderTimeTracker.js.map +1 -0
- package/dist/recyclerview/helpers/VelocityTracker.d.ts +29 -0
- package/dist/recyclerview/helpers/VelocityTracker.d.ts.map +1 -0
- package/dist/recyclerview/helpers/VelocityTracker.js +64 -0
- package/dist/recyclerview/helpers/VelocityTracker.js.map +1 -0
- package/dist/recyclerview/hooks/useBoundDetection.d.ts +17 -0
- package/dist/recyclerview/hooks/useBoundDetection.d.ts.map +1 -0
- package/dist/recyclerview/hooks/useBoundDetection.js +132 -0
- package/dist/recyclerview/hooks/useBoundDetection.js.map +1 -0
- package/dist/recyclerview/hooks/useLayoutState.d.ts +14 -0
- package/dist/recyclerview/hooks/useLayoutState.d.ts.map +1 -0
- package/dist/recyclerview/hooks/useLayoutState.js +38 -0
- package/dist/recyclerview/hooks/useLayoutState.js.map +1 -0
- package/dist/recyclerview/hooks/useMappingHelper.d.ts +9 -0
- package/dist/recyclerview/hooks/useMappingHelper.d.ts.map +1 -0
- package/dist/recyclerview/hooks/useMappingHelper.js +15 -0
- package/dist/recyclerview/hooks/useMappingHelper.js.map +1 -0
- package/dist/recyclerview/hooks/useOnLoad.d.ts +25 -0
- package/dist/recyclerview/hooks/useOnLoad.d.ts.map +1 -0
- package/dist/recyclerview/hooks/useOnLoad.js +67 -0
- package/dist/recyclerview/hooks/useOnLoad.js.map +1 -0
- package/dist/recyclerview/hooks/useRecyclerViewController.d.ts +28 -0
- package/dist/recyclerview/hooks/useRecyclerViewController.d.ts.map +1 -0
- package/dist/recyclerview/hooks/useRecyclerViewController.js +507 -0
- package/dist/recyclerview/hooks/useRecyclerViewController.js.map +1 -0
- package/dist/recyclerview/hooks/useRecyclerViewManager.d.ts +8 -0
- package/dist/recyclerview/hooks/useRecyclerViewManager.d.ts.map +1 -0
- package/dist/recyclerview/hooks/useRecyclerViewManager.js +32 -0
- package/dist/recyclerview/hooks/useRecyclerViewManager.js.map +1 -0
- package/dist/recyclerview/hooks/useRecyclingState.d.ts +18 -0
- package/dist/recyclerview/hooks/useRecyclingState.d.ts.map +1 -0
- package/dist/recyclerview/hooks/useRecyclingState.js +49 -0
- package/dist/recyclerview/hooks/useRecyclingState.js.map +1 -0
- package/dist/recyclerview/hooks/useSecondaryProps.d.ts +27 -0
- package/dist/recyclerview/hooks/useSecondaryProps.d.ts.map +1 -0
- package/dist/recyclerview/hooks/useSecondaryProps.js +90 -0
- package/dist/recyclerview/hooks/useSecondaryProps.js.map +1 -0
- package/dist/recyclerview/hooks/useUnmountAwareCallbacks.d.ts +15 -0
- package/dist/recyclerview/hooks/useUnmountAwareCallbacks.d.ts.map +1 -0
- package/dist/recyclerview/hooks/useUnmountAwareCallbacks.js +58 -0
- package/dist/recyclerview/hooks/useUnmountAwareCallbacks.js.map +1 -0
- package/dist/recyclerview/hooks/useUnmountFlag.d.ts +10 -0
- package/dist/recyclerview/hooks/useUnmountFlag.d.ts.map +1 -0
- package/dist/recyclerview/hooks/useUnmountFlag.js +25 -0
- package/dist/recyclerview/hooks/useUnmountFlag.js.map +1 -0
- package/dist/recyclerview/layout-managers/GridLayoutManager.d.ts +79 -0
- package/dist/recyclerview/layout-managers/GridLayoutManager.d.ts.map +1 -0
- package/dist/recyclerview/layout-managers/GridLayoutManager.js +221 -0
- package/dist/recyclerview/layout-managers/GridLayoutManager.js.map +1 -0
- package/dist/recyclerview/layout-managers/LayoutManager.d.ts +296 -0
- package/dist/recyclerview/layout-managers/LayoutManager.d.ts.map +1 -0
- package/dist/recyclerview/layout-managers/LayoutManager.js +279 -0
- package/dist/recyclerview/layout-managers/LayoutManager.js.map +1 -0
- package/dist/recyclerview/layout-managers/LinearLayoutManager.d.ts +51 -0
- package/dist/recyclerview/layout-managers/LinearLayoutManager.d.ts.map +1 -0
- package/dist/recyclerview/layout-managers/LinearLayoutManager.js +151 -0
- package/dist/recyclerview/layout-managers/LinearLayoutManager.js.map +1 -0
- package/dist/recyclerview/layout-managers/MasonryLayoutManager.d.ts +81 -0
- package/dist/recyclerview/layout-managers/MasonryLayoutManager.d.ts.map +1 -0
- package/dist/recyclerview/layout-managers/MasonryLayoutManager.js +269 -0
- package/dist/recyclerview/layout-managers/MasonryLayoutManager.js.map +1 -0
- package/dist/recyclerview/utils/adjustOffsetForRTL.d.ts +12 -0
- package/dist/recyclerview/utils/adjustOffsetForRTL.d.ts.map +1 -0
- package/dist/recyclerview/utils/adjustOffsetForRTL.js +14 -0
- package/dist/recyclerview/utils/adjustOffsetForRTL.js.map +1 -0
- package/dist/recyclerview/utils/componentUtils.d.ts +19 -0
- package/dist/recyclerview/utils/componentUtils.d.ts.map +1 -0
- package/dist/recyclerview/utils/componentUtils.js +27 -0
- package/dist/recyclerview/utils/componentUtils.js.map +1 -0
- package/dist/recyclerview/utils/findVisibleIndex.d.ts +24 -0
- package/dist/recyclerview/utils/findVisibleIndex.d.ts.map +1 -0
- package/dist/recyclerview/utils/findVisibleIndex.js +76 -0
- package/dist/recyclerview/utils/findVisibleIndex.js.map +1 -0
- package/dist/recyclerview/utils/measureLayout.d.ts +52 -0
- package/dist/recyclerview/utils/measureLayout.d.ts.map +1 -0
- package/dist/recyclerview/utils/measureLayout.js +99 -0
- package/dist/recyclerview/utils/measureLayout.js.map +1 -0
- package/dist/recyclerview/utils/measureLayout.web.d.ts +29 -0
- package/dist/recyclerview/utils/measureLayout.web.d.ts.map +1 -0
- package/dist/recyclerview/utils/measureLayout.web.js +79 -0
- package/dist/recyclerview/utils/measureLayout.web.js.map +1 -0
- package/dist/recyclerview/viewability/ViewToken.d.ts +8 -0
- package/dist/recyclerview/viewability/ViewToken.d.ts.map +1 -0
- package/dist/recyclerview/viewability/ViewToken.js +2 -0
- package/dist/recyclerview/viewability/ViewToken.js.map +1 -0
- package/dist/recyclerview/viewability/ViewabilityHelper.d.ts +26 -0
- package/dist/recyclerview/viewability/ViewabilityHelper.d.ts.map +1 -0
- package/dist/recyclerview/viewability/ViewabilityHelper.js +98 -0
- package/dist/recyclerview/viewability/ViewabilityHelper.js.map +1 -0
- package/dist/recyclerview/viewability/ViewabilityManager.d.ts +25 -0
- package/dist/recyclerview/viewability/ViewabilityManager.d.ts.map +1 -0
- package/dist/recyclerview/viewability/ViewabilityManager.js +94 -0
- package/dist/recyclerview/viewability/ViewabilityManager.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/AverageWindow.d.ts +33 -43
- package/dist/utils/AverageWindow.d.ts.map +1 -1
- package/dist/utils/AverageWindow.js +66 -71
- package/dist/utils/AverageWindow.js.map +1 -1
- package/jestSetup.js +23 -37
- package/package.json +15 -24
- package/src/AnimatedFlashList.ts +2 -25
- package/src/FlashList.ts +1 -0
- package/src/FlashListProps.ts +109 -100
- package/src/FlashListRef.ts +320 -0
- package/src/benchmark/AutoScrollHelper.ts +0 -24
- package/src/benchmark/JSFPSMonitor.ts +2 -26
- package/src/benchmark/roundToDecimalPlaces.ts +0 -24
- package/src/benchmark/useBenchmark.ts +59 -105
- package/src/benchmark/useDataMultiplier.ts +0 -24
- package/src/benchmark/useFlatListBenchmark.ts +43 -32
- package/src/errors/ErrorMessages.ts +26 -0
- package/src/errors/WarningMessages.ts +9 -0
- package/src/index.ts +18 -46
- package/src/isNewArch.ts +25 -0
- package/src/native/config/PlatformHelper.android.ts +3 -49
- package/src/native/config/PlatformHelper.harmony.ts +3 -24
- package/src/native/config/PlatformHelper.ios.ts +3 -48
- package/src/native/config/PlatformHelper.ts +3 -49
- package/src/native/config/PlatformHelper.web.ts +4 -55
- package/src/recyclerview/LayoutCommitObserver.tsx +74 -0
- package/src/recyclerview/RecyclerView.tsx +616 -0
- package/src/recyclerview/RecyclerViewContextProvider.ts +65 -0
- package/src/recyclerview/RecyclerViewManager.ts +461 -0
- package/src/recyclerview/RecyclerViewProps.ts +1 -0
- package/src/recyclerview/RenderStackManager.ts +317 -0
- package/src/recyclerview/ViewHolder.tsx +180 -0
- package/src/recyclerview/ViewHolderCollection.tsx +193 -0
- package/src/recyclerview/components/CompatScroller.ts +9 -0
- package/src/recyclerview/components/CompatView.ts +9 -0
- package/src/recyclerview/components/ScrollAnchor.tsx +66 -0
- package/src/recyclerview/components/StickyHeaders.tsx +222 -0
- package/src/recyclerview/helpers/ConsecutiveNumbers.ts +120 -0
- package/src/recyclerview/helpers/EngagedIndicesTracker.ts +301 -0
- package/src/recyclerview/helpers/RenderTimeTracker.ts +50 -0
- package/src/recyclerview/helpers/VelocityTracker.ts +77 -0
- package/src/recyclerview/hooks/useBoundDetection.ts +176 -0
- package/src/recyclerview/hooks/useLayoutState.ts +55 -0
- package/src/recyclerview/hooks/useMappingHelper.ts +20 -0
- package/src/recyclerview/hooks/useOnLoad.ts +80 -0
- package/src/recyclerview/hooks/useRecyclerViewController.tsx +633 -0
- package/src/recyclerview/hooks/useRecyclerViewManager.ts +42 -0
- package/src/recyclerview/hooks/useRecyclingState.ts +67 -0
- package/src/recyclerview/hooks/useSecondaryProps.tsx +124 -0
- package/src/recyclerview/hooks/useUnmountAwareCallbacks.ts +73 -0
- package/src/recyclerview/hooks/useUnmountFlag.ts +27 -0
- package/src/recyclerview/layout-managers/GridLayoutManager.ts +256 -0
- package/src/recyclerview/layout-managers/LayoutManager.ts +568 -0
- package/src/recyclerview/layout-managers/LinearLayoutManager.ts +171 -0
- package/src/recyclerview/layout-managers/MasonryLayoutManager.ts +323 -0
- package/src/recyclerview/utils/adjustOffsetForRTL.ts +17 -0
- package/src/recyclerview/utils/componentUtils.ts +28 -0
- package/src/recyclerview/utils/findVisibleIndex.ts +93 -0
- package/src/recyclerview/utils/measureLayout.ts +128 -0
- package/src/recyclerview/utils/measureLayout.web.ts +102 -0
- package/src/recyclerview/viewability/ViewToken.ts +7 -0
- package/src/{viewability → recyclerview/viewability}/ViewabilityHelper.ts +8 -33
- package/src/{viewability → recyclerview/viewability}/ViewabilityManager.ts +23 -46
- package/src/utils/AverageWindow.ts +33 -24
- package/dist/GridLayoutProviderWithProps.d.ts +0 -65
- package/dist/GridLayoutProviderWithProps.d.ts.map +0 -1
- package/dist/GridLayoutProviderWithProps.js +0 -138
- package/dist/GridLayoutProviderWithProps.js.map +0 -1
- package/dist/MasonryFlashList.d.ts +0 -74
- package/dist/MasonryFlashList.d.ts.map +0 -1
- package/dist/MasonryFlashList.js +0 -275
- package/dist/MasonryFlashList.js.map +0 -1
- package/dist/PureComponentWrapper.d.ts +0 -45
- package/dist/PureComponentWrapper.d.ts.map +0 -1
- package/dist/PureComponentWrapper.js +0 -60
- package/dist/PureComponentWrapper.js.map +0 -1
- package/dist/benchmark/useBlankAreaTracker.d.ts +0 -57
- package/dist/benchmark/useBlankAreaTracker.d.ts.map +0 -1
- package/dist/benchmark/useBlankAreaTracker.js +0 -90
- package/dist/benchmark/useBlankAreaTracker.js.map +0 -1
- package/dist/errors/CustomError.d.ts +0 -31
- package/dist/errors/CustomError.d.ts.map +0 -1
- package/dist/errors/CustomError.js +0 -37
- package/dist/errors/CustomError.js.map +0 -1
- package/dist/errors/ExceptionList.d.ts +0 -47
- package/dist/errors/ExceptionList.d.ts.map +0 -1
- package/dist/errors/ExceptionList.js +0 -49
- package/dist/errors/ExceptionList.js.map +0 -1
- package/dist/errors/Warnings.d.ts +0 -32
- package/dist/errors/Warnings.d.ts.map +0 -1
- package/dist/errors/Warnings.js +0 -36
- package/dist/errors/Warnings.js.map +0 -1
- package/dist/fabric/AutoLayoutNativeComponent.d.ts +0 -42
- package/dist/fabric/AutoLayoutNativeComponent.d.ts.map +0 -1
- package/dist/fabric/AutoLayoutNativeComponent.js +0 -29
- package/dist/fabric/AutoLayoutNativeComponent.js.map +0 -1
- package/dist/fabric/CellContainerNativeComponent.d.ts +0 -31
- package/dist/fabric/CellContainerNativeComponent.d.ts.map +0 -1
- package/dist/fabric/CellContainerNativeComponent.js +0 -29
- package/dist/fabric/CellContainerNativeComponent.js.map +0 -1
- package/dist/native/auto-layout/AutoLayoutView.d.ts +0 -45
- package/dist/native/auto-layout/AutoLayoutView.d.ts.map +0 -1
- package/dist/native/auto-layout/AutoLayoutView.js +0 -71
- package/dist/native/auto-layout/AutoLayoutView.js.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.d.ts +0 -27
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.d.ts.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.js +0 -29
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.js.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.d.ts +0 -28
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.d.ts.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.harmony.d.ts +0 -27
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.harmony.d.ts.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.harmony.js +0 -29
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.harmony.js.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.d.ts +0 -27
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.d.ts.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.js +0 -29
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.js.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.js +0 -29
- package/dist/native/auto-layout/AutoLayoutViewNativeComponent.js.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.d.ts +0 -39
- package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.d.ts.map +0 -1
- package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.js +0 -26
- package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.js.map +0 -1
- package/dist/native/cell-container/CellContainer.android.d.ts +0 -29
- package/dist/native/cell-container/CellContainer.android.d.ts.map +0 -1
- package/dist/native/cell-container/CellContainer.android.js +0 -32
- package/dist/native/cell-container/CellContainer.android.js.map +0 -1
- package/dist/native/cell-container/CellContainer.d.ts +0 -31
- package/dist/native/cell-container/CellContainer.d.ts.map +0 -1
- package/dist/native/cell-container/CellContainer.harmony.d.ts +0 -29
- package/dist/native/cell-container/CellContainer.harmony.d.ts.map +0 -1
- package/dist/native/cell-container/CellContainer.harmony.js +0 -32
- package/dist/native/cell-container/CellContainer.harmony.js.map +0 -1
- package/dist/native/cell-container/CellContainer.ios.d.ts +0 -29
- package/dist/native/cell-container/CellContainer.ios.d.ts.map +0 -1
- package/dist/native/cell-container/CellContainer.ios.js +0 -32
- package/dist/native/cell-container/CellContainer.ios.js.map +0 -1
- package/dist/native/cell-container/CellContainer.js +0 -34
- package/dist/native/cell-container/CellContainer.js.map +0 -1
- package/dist/native/cell-container/CellContainer.web.d.ts +0 -30
- package/dist/native/cell-container/CellContainer.web.d.ts.map +0 -1
- package/dist/native/cell-container/CellContainer.web.js +0 -36
- package/dist/native/cell-container/CellContainer.web.js.map +0 -1
- package/dist/utils/ContentContainerUtils.d.ts +0 -50
- package/dist/utils/ContentContainerUtils.d.ts.map +0 -1
- package/dist/utils/ContentContainerUtils.js +0 -71
- package/dist/utils/ContentContainerUtils.js.map +0 -1
- package/dist/viewability/ViewToken.d.ts +0 -31
- package/dist/viewability/ViewToken.d.ts.map +0 -1
- package/dist/viewability/ViewToken.js +0 -26
- package/dist/viewability/ViewToken.js.map +0 -1
- package/dist/viewability/ViewabilityHelper.d.ts +0 -49
- package/dist/viewability/ViewabilityHelper.d.ts.map +0 -1
- package/dist/viewability/ViewabilityHelper.js +0 -130
- package/dist/viewability/ViewabilityHelper.js.map +0 -1
- package/dist/viewability/ViewabilityManager.d.ts +0 -48
- package/dist/viewability/ViewabilityManager.d.ts.map +0 -1
- package/dist/viewability/ViewabilityManager.js +0 -131
- package/dist/viewability/ViewabilityManager.js.map +0 -1
- package/harmony/flash_list/BuildProfile.ets +0 -17
- package/harmony/flash_list/LICENSE +0 -7
- package/harmony/flash_list/build-profile.json5 +0 -8
- package/harmony/flash_list/hvigorfile.ts +0 -1
- package/harmony/flash_list/index.ets +0 -27
- package/harmony/flash_list/obfuscation-rules.txt +0 -18
- package/harmony/flash_list/oh-package.json5 +0 -24
- package/harmony/flash_list/src/main/cpp/AutoLayoutNode.cpp +0 -63
- package/harmony/flash_list/src/main/cpp/AutoLayoutNode.h +0 -54
- package/harmony/flash_list/src/main/cpp/AutoLayoutShadow.cpp +0 -140
- package/harmony/flash_list/src/main/cpp/AutoLayoutShadow.h +0 -66
- package/harmony/flash_list/src/main/cpp/AutoLayoutViewComponentInstance.cpp +0 -208
- package/harmony/flash_list/src/main/cpp/AutoLayoutViewComponentInstance.h +0 -78
- package/harmony/flash_list/src/main/cpp/AutoLayoutViewEventEmitRequestHandler.h +0 -53
- package/harmony/flash_list/src/main/cpp/AutoLayoutViewJSIBinder.h +0 -50
- package/harmony/flash_list/src/main/cpp/CMakeLists.txt +0 -12
- package/harmony/flash_list/src/main/cpp/CellContainerComponentInstance.cpp +0 -80
- package/harmony/flash_list/src/main/cpp/CellContainerComponentInstance.h +0 -64
- package/harmony/flash_list/src/main/cpp/CellContainerJSIBinder.h +0 -39
- package/harmony/flash_list/src/main/cpp/ComponentDescriptors.h +0 -40
- package/harmony/flash_list/src/main/cpp/EventEmitters.cpp +0 -40
- package/harmony/flash_list/src/main/cpp/EventEmitters.h +0 -48
- package/harmony/flash_list/src/main/cpp/FlashListPackage.h +0 -85
- package/harmony/flash_list/src/main/cpp/FlashListStackNode.cpp +0 -87
- package/harmony/flash_list/src/main/cpp/FlashListStackNode.h +0 -57
- package/harmony/flash_list/src/main/cpp/Props.cpp +0 -52
- package/harmony/flash_list/src/main/cpp/Props.h +0 -64
- package/harmony/flash_list/src/main/cpp/ShadowNodes.cpp +0 -34
- package/harmony/flash_list/src/main/cpp/ShadowNodes.h +0 -48
- package/harmony/flash_list/src/main/ets/Logger.ets +0 -64
- package/harmony/flash_list/src/main/ets/RNAutoLayoutShadow.ets +0 -154
- package/harmony/flash_list/src/main/ets/RNAutoLayoutView.ets +0 -277
- package/harmony/flash_list/src/main/ets/RNCellContainer.ets +0 -113
- package/harmony/flash_list/src/main/module.json5 +0 -9
- package/harmony/flash_list/src/main/resources/base/element/color.json +0 -8
- package/harmony/flash_list/src/main/resources/base/element/string.json +0 -16
- package/harmony/flash_list/src/main/resources/base/media/icon.png +0 -0
- package/harmony/flash_list/src/main/resources/base/profile/main_pages.json +0 -5
- package/harmony/flash_list/src/main/resources/en_US/element/string.json +0 -16
- package/harmony/flash_list/src/main/resources/zh_CN/element/string.json +0 -16
- package/harmony/flash_list.har +0 -0
- package/src/FlashList.tsx +0 -949
- package/src/GridLayoutProviderWithProps.ts +0 -204
- package/src/MasonryFlashList.tsx +0 -499
- package/src/PureComponentWrapper.tsx +0 -65
- package/src/benchmark/useBlankAreaTracker.ts +0 -141
- package/src/errors/CustomError.ts +0 -34
- package/src/errors/ExceptionList.ts +0 -52
- package/src/errors/Warnings.ts +0 -39
- package/src/fabric/AutoLayoutNativeComponent.ts +0 -52
- package/src/fabric/CellContainerNativeComponent.ts +0 -35
- package/src/native/auto-layout/AutoLayoutView.tsx +0 -97
- package/src/native/auto-layout/AutoLayoutViewNativeComponent.android.ts +0 -31
- package/src/native/auto-layout/AutoLayoutViewNativeComponent.harmony.ts +0 -31
- package/src/native/auto-layout/AutoLayoutViewNativeComponent.ios.ts +0 -31
- package/src/native/auto-layout/AutoLayoutViewNativeComponent.ts +0 -31
- package/src/native/auto-layout/AutoLayoutViewNativeComponentProps.ts +0 -41
- package/src/native/cell-container/CellContainer.android.ts +0 -31
- package/src/native/cell-container/CellContainer.harmony.ts +0 -31
- package/src/native/cell-container/CellContainer.ios.ts +0 -31
- package/src/native/cell-container/CellContainer.tsx +0 -38
- package/src/native/cell-container/CellContainer.web.tsx +0 -33
- package/src/utils/ContentContainerUtils.ts +0 -116
- package/src/viewability/ViewToken.ts +0 -31
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useCallback } from "react";
|
|
2
|
+
import { useRecyclerViewContext } from "../RecyclerViewContextProvider";
|
|
3
|
+
/**
|
|
4
|
+
* Returns a function that can help create a mapping key for the items.
|
|
5
|
+
* Useful when doing .map on items to create a list of components.
|
|
6
|
+
* Using this ensures that performance is optimal for FlashList
|
|
7
|
+
*/
|
|
8
|
+
export const useMappingHelper = () => {
|
|
9
|
+
const recyclerViewContext = useRecyclerViewContext();
|
|
10
|
+
const getMappingKey = useCallback((itemKey, index) => {
|
|
11
|
+
return recyclerViewContext ? index : itemKey;
|
|
12
|
+
}, [recyclerViewContext]);
|
|
13
|
+
return { getMappingKey };
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=useMappingHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMappingHelper.js","sourceRoot":"","sources":["../../../src/recyclerview/hooks/useMappingHelper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAEpC,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAExE;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,EAAE;IACnC,MAAM,mBAAmB,GAAG,sBAAsB,EAAE,CAAC;IACrD,MAAM,aAAa,GAAG,WAAW,CAC/B,CAAC,OAAiC,EAAE,KAAa,EAAE,EAAE;QACnD,OAAO,mBAAmB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC;IAC/C,CAAC,EACD,CAAC,mBAAmB,CAAC,CACtB,CAAC;IAEF,OAAO,EAAE,aAAa,EAAE,CAAC;AAC3B,CAAC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { RecyclerViewManager } from "../RecyclerViewManager";
|
|
2
|
+
/**
|
|
3
|
+
* Hook to track when the RecyclerView has loaded its items and notify when loading is complete.
|
|
4
|
+
* Similar to FlashList's onLoad functionality, this hook tracks the time it takes to render
|
|
5
|
+
* the initial set of items in the RecyclerView and provides performance metrics.
|
|
6
|
+
*
|
|
7
|
+
* @param recyclerViewManager - The RecyclerViewManager instance managing the list
|
|
8
|
+
* @param onLoad - Optional callback function that will be called when the list has loaded with timing information
|
|
9
|
+
* @returns Object containing isLoaded state indicating whether the list has completed initial rendering
|
|
10
|
+
*/
|
|
11
|
+
export declare const useOnListLoad: <T>(recyclerViewManager: RecyclerViewManager<T>, onLoad?: (info: {
|
|
12
|
+
elapsedTimeInMs: number;
|
|
13
|
+
}) => void) => {
|
|
14
|
+
isLoaded: boolean;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Core hook that detects when a RecyclerView has completed its initial layout.
|
|
18
|
+
* This hook monitors the RecyclerViewManager and triggers the provided callback
|
|
19
|
+
* once the first layout is complete.
|
|
20
|
+
*
|
|
21
|
+
* @param recyclerViewManager - The RecyclerViewManager instance to monitor
|
|
22
|
+
* @param onLoad - Callback function that will be called once when the first layout is complete
|
|
23
|
+
*/
|
|
24
|
+
export declare const useOnLoad: <T>(recyclerViewManager: RecyclerViewManager<T>, onLoad: () => void) => void;
|
|
25
|
+
//# sourceMappingURL=useOnLoad.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useOnLoad.d.ts","sourceRoot":"","sources":["../../../src/recyclerview/hooks/useOnLoad.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAK7D;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,GAAI,CAAC,EAC7B,qBAAqB,mBAAmB,CAAC,CAAC,CAAC,EAC3C,SAAS,CAAC,IAAI,EAAE;IAAE,eAAe,EAAE,MAAM,CAAA;CAAE,KAAK,IAAI,KACnD;IAAE,QAAQ,EAAE,OAAO,CAAA;CAsCrB,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,GAAI,CAAC,EACzB,qBAAqB,mBAAmB,CAAC,CAAC,CAAC,EAC3C,QAAQ,MAAM,IAAI,SAUnB,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
2
|
+
import { useUnmountAwareAnimationFrame } from "./useUnmountAwareCallbacks";
|
|
3
|
+
// import { ToastAndroid } from "react-native";
|
|
4
|
+
/**
|
|
5
|
+
* Hook to track when the RecyclerView has loaded its items and notify when loading is complete.
|
|
6
|
+
* Similar to FlashList's onLoad functionality, this hook tracks the time it takes to render
|
|
7
|
+
* the initial set of items in the RecyclerView and provides performance metrics.
|
|
8
|
+
*
|
|
9
|
+
* @param recyclerViewManager - The RecyclerViewManager instance managing the list
|
|
10
|
+
* @param onLoad - Optional callback function that will be called when the list has loaded with timing information
|
|
11
|
+
* @returns Object containing isLoaded state indicating whether the list has completed initial rendering
|
|
12
|
+
*/
|
|
13
|
+
export const useOnListLoad = (recyclerViewManager, onLoad) => {
|
|
14
|
+
const loadStartTimeRef = useRef(Date.now());
|
|
15
|
+
const [isLoaded, setIsLoaded] = useState(false);
|
|
16
|
+
const dataLength = recyclerViewManager.getDataLength();
|
|
17
|
+
// const dataCollector = useRef<number[]>([]);
|
|
18
|
+
const { requestAnimationFrame } = useUnmountAwareAnimationFrame();
|
|
19
|
+
// Track render cycles by collecting elapsed time on each render
|
|
20
|
+
// useEffect(() => {
|
|
21
|
+
// const elapsedTimeInMs = Date.now() - loadStartTimeRef.current;
|
|
22
|
+
// dataCollector.current?.push(elapsedTimeInMs);
|
|
23
|
+
// });
|
|
24
|
+
useMemo(() => {
|
|
25
|
+
loadStartTimeRef.current = Date.now();
|
|
26
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
27
|
+
}, [dataLength]);
|
|
28
|
+
useOnLoad(recyclerViewManager, () => {
|
|
29
|
+
const elapsedTimeInMs = Date.now() - loadStartTimeRef.current;
|
|
30
|
+
// Commented code below was used for debugging purposes
|
|
31
|
+
// to display all collected timing data points
|
|
32
|
+
// const dataCollectorString = dataCollector.current
|
|
33
|
+
// ?.map((value) => value.toString())
|
|
34
|
+
// .join(", ");
|
|
35
|
+
// ToastAndroid?.show(
|
|
36
|
+
// `onLoad called after ${dataCollectorString}`,
|
|
37
|
+
// ToastAndroid.SHORT
|
|
38
|
+
// );
|
|
39
|
+
// console.log("----------> dataCollector", dataCollectorString);
|
|
40
|
+
// console.log("----------> FlashList v2 load in", `${elapsedTimeInMs} ms`);
|
|
41
|
+
requestAnimationFrame(() => {
|
|
42
|
+
recyclerViewManager.isFirstPaintOnUiComplete = true;
|
|
43
|
+
onLoad === null || onLoad === void 0 ? void 0 : onLoad({ elapsedTimeInMs });
|
|
44
|
+
setIsLoaded(true);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
return { isLoaded };
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Core hook that detects when a RecyclerView has completed its initial layout.
|
|
51
|
+
* This hook monitors the RecyclerViewManager and triggers the provided callback
|
|
52
|
+
* once the first layout is complete.
|
|
53
|
+
*
|
|
54
|
+
* @param recyclerViewManager - The RecyclerViewManager instance to monitor
|
|
55
|
+
* @param onLoad - Callback function that will be called once when the first layout is complete
|
|
56
|
+
*/
|
|
57
|
+
export const useOnLoad = (recyclerViewManager, onLoad) => {
|
|
58
|
+
const isLoaded = useRef(false);
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
// Only trigger onLoad callback once when first layout is complete
|
|
61
|
+
if (recyclerViewManager.getIsFirstLayoutComplete() && !isLoaded.current) {
|
|
62
|
+
isLoaded.current = true;
|
|
63
|
+
onLoad();
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
//# sourceMappingURL=useOnLoad.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useOnLoad.js","sourceRoot":"","sources":["../../../src/recyclerview/hooks/useOnLoad.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAI7D,OAAO,EAAE,6BAA6B,EAAE,MAAM,4BAA4B,CAAC;AAC3E,+CAA+C;AAE/C;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,mBAA2C,EAC3C,MAAoD,EAC7B,EAAE;IACzB,MAAM,gBAAgB,GAAG,MAAM,CAAS,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;IACpD,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAU,KAAK,CAAC,CAAC;IACzD,MAAM,UAAU,GAAG,mBAAmB,CAAC,aAAa,EAAE,CAAC;IACvD,8CAA8C;IAC9C,MAAM,EAAE,qBAAqB,EAAE,GAAG,6BAA6B,EAAE,CAAC;IAClE,gEAAgE;IAChE,oBAAoB;IACpB,mEAAmE;IACnE,kDAAkD;IAClD,MAAM;IAEN,OAAO,CAAC,GAAG,EAAE;QACX,gBAAgB,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACtC,uDAAuD;IACzD,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAEjB,SAAS,CAAC,mBAAmB,EAAE,GAAG,EAAE;QAClC,MAAM,eAAe,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,gBAAgB,CAAC,OAAO,CAAC;QAC9D,uDAAuD;QACvD,8CAA8C;QAC9C,oDAAoD;QACpD,uCAAuC;QACvC,iBAAiB;QACjB,sBAAsB;QACtB,kDAAkD;QAClD,uBAAuB;QACvB,KAAK;QACL,iEAAiE;QACjE,4EAA4E;QAC5E,qBAAqB,CAAC,GAAG,EAAE;YACzB,mBAAmB,CAAC,wBAAwB,GAAG,IAAI,CAAC;YACpD,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAG,EAAE,eAAe,EAAE,CAAC,CAAC;YAC9B,WAAW,CAAC,IAAI,CAAC,CAAC;QACpB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,QAAQ,EAAE,CAAC;AACtB,CAAC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,mBAA2C,EAC3C,MAAkB,EAClB,EAAE;IACF,MAAM,QAAQ,GAAG,MAAM,CAAU,KAAK,CAAC,CAAC;IACxC,SAAS,CAAC,GAAG,EAAE;QACb,kEAAkE;QAClE,IAAI,mBAAmB,CAAC,wBAAwB,EAAE,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;YACxE,QAAQ,CAAC,OAAO,GAAG,IAAI,CAAC;YACxB,MAAM,EAAE,CAAC;QACX,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { RefObject } from "react";
|
|
2
|
+
import { FlashListRef } from "../../FlashListRef";
|
|
3
|
+
import { CompatScroller } from "../components/CompatScroller";
|
|
4
|
+
import { RecyclerViewManager } from "../RecyclerViewManager";
|
|
5
|
+
import { ScrollAnchorRef } from "../components/ScrollAnchor";
|
|
6
|
+
/**
|
|
7
|
+
* Comprehensive hook that manages RecyclerView scrolling behavior and provides
|
|
8
|
+
* imperative methods for controlling the RecyclerView.
|
|
9
|
+
*
|
|
10
|
+
* This hook combines content offset management and scroll handling functionality:
|
|
11
|
+
* 1. Provides imperative methods for scrolling and measurement
|
|
12
|
+
* 2. Handles initial scroll position when the list first loads
|
|
13
|
+
* 3. Maintains visible content position during updates
|
|
14
|
+
* 4. Manages scroll anchors for chat-like applications
|
|
15
|
+
*
|
|
16
|
+
* @param recyclerViewManager - The RecyclerViewManager instance that handles core functionality
|
|
17
|
+
* @param ref - The ref to expose the imperative methods
|
|
18
|
+
* @param scrollViewRef - Reference to the scrollable container component
|
|
19
|
+
* @param scrollAnchorRef - Reference to the scroll anchor component
|
|
20
|
+
* @param props - The RecyclerViewProps containing configuration
|
|
21
|
+
*/
|
|
22
|
+
export declare function useRecyclerViewController<T>(recyclerViewManager: RecyclerViewManager<T>, ref: React.Ref<FlashListRef<T>>, scrollViewRef: RefObject<CompatScroller>, scrollAnchorRef: React.RefObject<ScrollAnchorRef>): {
|
|
23
|
+
applyOffsetCorrection: () => void;
|
|
24
|
+
computeFirstVisibleIndexForOffsetCorrection: () => void;
|
|
25
|
+
applyInitialScrollIndex: () => void;
|
|
26
|
+
handlerMethods: FlashListRef<T>;
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=useRecyclerViewController.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRecyclerViewController.d.ts","sourceRoot":"","sources":["../../../src/recyclerview/hooks/useRecyclerViewController.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAMV,MAAM,OAAO,CAAC;AAGf,OAAO,EAKL,YAAY,EACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAG7D,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAO7D;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,yBAAyB,CAAC,CAAC,EACzC,mBAAmB,EAAE,mBAAmB,CAAC,CAAC,CAAC,EAC3C,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EAC/B,aAAa,EAAE,SAAS,CAAC,cAAc,CAAC,EACxC,eAAe,EAAE,KAAK,CAAC,SAAS,CAAC,eAAe,CAAC;;;;;EAwkBlD"}
|
|
@@ -0,0 +1,507 @@
|
|
|
1
|
+
import { useCallback, useImperativeHandle, useMemo, useRef, useState, } from "react";
|
|
2
|
+
import { I18nManager } from "react-native";
|
|
3
|
+
import { adjustOffsetForRTL } from "../utils/adjustOffsetForRTL";
|
|
4
|
+
import { PlatformConfig } from "../../native/config/PlatformHelper";
|
|
5
|
+
import { WarningMessages } from "../../errors/WarningMessages";
|
|
6
|
+
import { useUnmountFlag } from "./useUnmountFlag";
|
|
7
|
+
import { useUnmountAwareTimeout } from "./useUnmountAwareCallbacks";
|
|
8
|
+
/**
|
|
9
|
+
* Comprehensive hook that manages RecyclerView scrolling behavior and provides
|
|
10
|
+
* imperative methods for controlling the RecyclerView.
|
|
11
|
+
*
|
|
12
|
+
* This hook combines content offset management and scroll handling functionality:
|
|
13
|
+
* 1. Provides imperative methods for scrolling and measurement
|
|
14
|
+
* 2. Handles initial scroll position when the list first loads
|
|
15
|
+
* 3. Maintains visible content position during updates
|
|
16
|
+
* 4. Manages scroll anchors for chat-like applications
|
|
17
|
+
*
|
|
18
|
+
* @param recyclerViewManager - The RecyclerViewManager instance that handles core functionality
|
|
19
|
+
* @param ref - The ref to expose the imperative methods
|
|
20
|
+
* @param scrollViewRef - Reference to the scrollable container component
|
|
21
|
+
* @param scrollAnchorRef - Reference to the scroll anchor component
|
|
22
|
+
* @param props - The RecyclerViewProps containing configuration
|
|
23
|
+
*/
|
|
24
|
+
export function useRecyclerViewController(recyclerViewManager, ref, scrollViewRef, scrollAnchorRef) {
|
|
25
|
+
const isUnmounted = useUnmountFlag();
|
|
26
|
+
const [_, setRenderId] = useState(0);
|
|
27
|
+
const pauseOffsetCorrection = useRef(false);
|
|
28
|
+
const initialScrollCompletedRef = useRef(false);
|
|
29
|
+
const lastDataLengthRef = useRef(recyclerViewManager.getDataLength());
|
|
30
|
+
const { setTimeout } = useUnmountAwareTimeout();
|
|
31
|
+
// Track the first visible item for maintaining scroll position
|
|
32
|
+
const firstVisibleItemKey = useRef(undefined);
|
|
33
|
+
const firstVisibleItemLayout = useRef(undefined);
|
|
34
|
+
// Queue to store callbacks that should be executed after scroll offset updates
|
|
35
|
+
const pendingScrollCallbacks = useRef([]);
|
|
36
|
+
// Handle initial scroll position when the list first loads
|
|
37
|
+
// useOnLoad(recyclerViewManager, () => {
|
|
38
|
+
// });
|
|
39
|
+
/**
|
|
40
|
+
* Updates the scroll offset and calls the provided callback
|
|
41
|
+
* after the update has been applied and the component has re-rendered.
|
|
42
|
+
*
|
|
43
|
+
* @param offset - The new scroll offset to apply
|
|
44
|
+
* @param callback - Optional callback to execute after the update is applied
|
|
45
|
+
*/
|
|
46
|
+
const updateScrollOffsetWithCallback = useCallback((offset, callback) => {
|
|
47
|
+
// Attempt to update the scroll offset in the RecyclerViewManager
|
|
48
|
+
// This returns undefined if no update is needed
|
|
49
|
+
if (recyclerViewManager.updateScrollOffset(offset) !== undefined) {
|
|
50
|
+
// It will be executed after the next render
|
|
51
|
+
pendingScrollCallbacks.current.push(callback);
|
|
52
|
+
// Trigger a re-render to apply the scroll offset update
|
|
53
|
+
setRenderId((prev) => prev + 1);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
// No update needed, execute callback immediately
|
|
57
|
+
callback();
|
|
58
|
+
}
|
|
59
|
+
}, [recyclerViewManager]);
|
|
60
|
+
const computeFirstVisibleIndexForOffsetCorrection = useCallback(() => {
|
|
61
|
+
if (recyclerViewManager.getIsFirstLayoutComplete() &&
|
|
62
|
+
recyclerViewManager.hasStableDataKeys() &&
|
|
63
|
+
recyclerViewManager.getDataLength() > 0 &&
|
|
64
|
+
recyclerViewManager.shouldMaintainVisibleContentPosition()) {
|
|
65
|
+
// Update the tracked first visible item
|
|
66
|
+
const firstVisibleIndex = Math.max(0, recyclerViewManager.computeVisibleIndices().startIndex);
|
|
67
|
+
if (firstVisibleIndex !== undefined && firstVisibleIndex >= 0) {
|
|
68
|
+
firstVisibleItemKey.current =
|
|
69
|
+
recyclerViewManager.getDataKey(firstVisibleIndex);
|
|
70
|
+
firstVisibleItemLayout.current = {
|
|
71
|
+
...recyclerViewManager.getLayout(firstVisibleIndex),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}, [recyclerViewManager]);
|
|
76
|
+
/**
|
|
77
|
+
* Maintains the visible content position when the list updates.
|
|
78
|
+
* This is particularly useful for chat applications where we want to keep
|
|
79
|
+
* the user's current view position when new messages are added.
|
|
80
|
+
*/
|
|
81
|
+
const applyOffsetCorrection = useCallback(() => {
|
|
82
|
+
var _a, _b, _c;
|
|
83
|
+
const { horizontal, data } = recyclerViewManager.props;
|
|
84
|
+
// Execute all pending callbacks from previous scroll offset updates
|
|
85
|
+
// This ensures any scroll operations that were waiting for render are completed
|
|
86
|
+
const callbacks = pendingScrollCallbacks.current;
|
|
87
|
+
pendingScrollCallbacks.current = [];
|
|
88
|
+
callbacks.forEach((callback) => callback());
|
|
89
|
+
const currentDataLength = recyclerViewManager.getDataLength();
|
|
90
|
+
if (recyclerViewManager.getIsFirstLayoutComplete() &&
|
|
91
|
+
recyclerViewManager.hasStableDataKeys() &&
|
|
92
|
+
currentDataLength > 0 &&
|
|
93
|
+
recyclerViewManager.shouldMaintainVisibleContentPosition()) {
|
|
94
|
+
const hasDataChanged = currentDataLength !== lastDataLengthRef.current;
|
|
95
|
+
// If we have a tracked first visible item, maintain its position
|
|
96
|
+
if (firstVisibleItemKey.current) {
|
|
97
|
+
const currentIndexOfFirstVisibleItem = (_a = recyclerViewManager
|
|
98
|
+
.getEngagedIndices()
|
|
99
|
+
.findValue((index) => recyclerViewManager.getDataKey(index) ===
|
|
100
|
+
firstVisibleItemKey.current)) !== null && _a !== void 0 ? _a : (hasDataChanged
|
|
101
|
+
? data === null || data === void 0 ? void 0 : data.findIndex((item, index) => recyclerViewManager.getDataKey(index) ===
|
|
102
|
+
firstVisibleItemKey.current)
|
|
103
|
+
: undefined);
|
|
104
|
+
if (currentIndexOfFirstVisibleItem !== undefined &&
|
|
105
|
+
currentIndexOfFirstVisibleItem >= 0) {
|
|
106
|
+
// Calculate the difference in position and apply the offset
|
|
107
|
+
const diff = horizontal
|
|
108
|
+
? recyclerViewManager.getLayout(currentIndexOfFirstVisibleItem).x -
|
|
109
|
+
firstVisibleItemLayout.current.x
|
|
110
|
+
: recyclerViewManager.getLayout(currentIndexOfFirstVisibleItem).y -
|
|
111
|
+
firstVisibleItemLayout.current.y;
|
|
112
|
+
firstVisibleItemLayout.current = {
|
|
113
|
+
...recyclerViewManager.getLayout(currentIndexOfFirstVisibleItem),
|
|
114
|
+
};
|
|
115
|
+
if (diff !== 0 &&
|
|
116
|
+
!pauseOffsetCorrection.current &&
|
|
117
|
+
!recyclerViewManager.animationOptimizationsEnabled) {
|
|
118
|
+
// console.log("diff", diff, firstVisibleItemKey.current);
|
|
119
|
+
if (PlatformConfig.supportsOffsetCorrection) {
|
|
120
|
+
// console.log("scrollBy", diff);
|
|
121
|
+
(_b = scrollAnchorRef.current) === null || _b === void 0 ? void 0 : _b.scrollBy(diff);
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
const scrollToParams = horizontal
|
|
125
|
+
? {
|
|
126
|
+
x: recyclerViewManager.getAbsoluteLastScrollOffset() + diff,
|
|
127
|
+
animated: false,
|
|
128
|
+
}
|
|
129
|
+
: {
|
|
130
|
+
y: recyclerViewManager.getAbsoluteLastScrollOffset() + diff,
|
|
131
|
+
animated: false,
|
|
132
|
+
};
|
|
133
|
+
(_c = scrollViewRef.current) === null || _c === void 0 ? void 0 : _c.scrollTo(scrollToParams);
|
|
134
|
+
}
|
|
135
|
+
if (hasDataChanged) {
|
|
136
|
+
updateScrollOffsetWithCallback(recyclerViewManager.getAbsoluteLastScrollOffset() + diff, () => { });
|
|
137
|
+
recyclerViewManager.ignoreScrollEvents = true;
|
|
138
|
+
setTimeout(() => {
|
|
139
|
+
recyclerViewManager.ignoreScrollEvents = false;
|
|
140
|
+
}, 100);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
computeFirstVisibleIndexForOffsetCorrection();
|
|
146
|
+
}
|
|
147
|
+
lastDataLengthRef.current = recyclerViewManager.getDataLength();
|
|
148
|
+
}, [
|
|
149
|
+
recyclerViewManager,
|
|
150
|
+
scrollAnchorRef,
|
|
151
|
+
scrollViewRef,
|
|
152
|
+
setTimeout,
|
|
153
|
+
updateScrollOffsetWithCallback,
|
|
154
|
+
computeFirstVisibleIndexForOffsetCorrection,
|
|
155
|
+
]);
|
|
156
|
+
const handlerMethods = useMemo(() => {
|
|
157
|
+
return {
|
|
158
|
+
get props() {
|
|
159
|
+
return recyclerViewManager.props;
|
|
160
|
+
},
|
|
161
|
+
/**
|
|
162
|
+
* Scrolls the list to a specific offset position.
|
|
163
|
+
* Handles RTL layouts and first item offset adjustments.
|
|
164
|
+
*/
|
|
165
|
+
scrollToOffset: ({ offset, animated, skipFirstItemOffset = true, }) => {
|
|
166
|
+
const { horizontal } = recyclerViewManager.props;
|
|
167
|
+
if (scrollViewRef.current) {
|
|
168
|
+
// Adjust offset for RTL layouts in horizontal mode
|
|
169
|
+
if (I18nManager.isRTL && horizontal) {
|
|
170
|
+
// eslint-disable-next-line no-param-reassign
|
|
171
|
+
offset =
|
|
172
|
+
adjustOffsetForRTL(offset, recyclerViewManager.getChildContainerDimensions().width, recyclerViewManager.getWindowSize().width) +
|
|
173
|
+
(skipFirstItemOffset
|
|
174
|
+
? recyclerViewManager.firstItemOffset
|
|
175
|
+
: -recyclerViewManager.firstItemOffset);
|
|
176
|
+
}
|
|
177
|
+
// Calculate the final offset including first item offset if needed
|
|
178
|
+
const adjustedOffset = offset +
|
|
179
|
+
(skipFirstItemOffset ? 0 : recyclerViewManager.firstItemOffset);
|
|
180
|
+
const scrollTo = horizontal
|
|
181
|
+
? { x: adjustedOffset, y: 0 }
|
|
182
|
+
: { x: 0, y: adjustedOffset };
|
|
183
|
+
scrollViewRef.current.scrollTo({
|
|
184
|
+
...scrollTo,
|
|
185
|
+
animated,
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
clearLayoutCacheOnUpdate: () => {
|
|
190
|
+
recyclerViewManager.markLayoutManagerDirty();
|
|
191
|
+
},
|
|
192
|
+
// Expose native scroll view methods
|
|
193
|
+
flashScrollIndicators: () => {
|
|
194
|
+
scrollViewRef.current.flashScrollIndicators();
|
|
195
|
+
},
|
|
196
|
+
getNativeScrollRef: () => {
|
|
197
|
+
return scrollViewRef.current;
|
|
198
|
+
},
|
|
199
|
+
getScrollResponder: () => {
|
|
200
|
+
return scrollViewRef.current.getScrollResponder();
|
|
201
|
+
},
|
|
202
|
+
getScrollableNode: () => {
|
|
203
|
+
return scrollViewRef.current.getScrollableNode();
|
|
204
|
+
},
|
|
205
|
+
/**
|
|
206
|
+
* Scrolls to the end of the list.
|
|
207
|
+
*/
|
|
208
|
+
scrollToEnd: async ({ animated } = {}) => {
|
|
209
|
+
const { data } = recyclerViewManager.props;
|
|
210
|
+
if (data && data.length > 0) {
|
|
211
|
+
const lastIndex = data.length - 1;
|
|
212
|
+
if (!recyclerViewManager.getEngagedIndices().includes(lastIndex)) {
|
|
213
|
+
await handlerMethods.scrollToIndex({
|
|
214
|
+
index: lastIndex,
|
|
215
|
+
animated,
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
setTimeout(() => {
|
|
220
|
+
var _a;
|
|
221
|
+
(_a = scrollViewRef.current) === null || _a === void 0 ? void 0 : _a.scrollToEnd({ animated });
|
|
222
|
+
}, 0);
|
|
223
|
+
},
|
|
224
|
+
/**
|
|
225
|
+
* Scrolls to the beginning of the list.
|
|
226
|
+
*/
|
|
227
|
+
scrollToTop: ({ animated } = {}) => {
|
|
228
|
+
handlerMethods.scrollToOffset({
|
|
229
|
+
offset: 0,
|
|
230
|
+
animated,
|
|
231
|
+
});
|
|
232
|
+
},
|
|
233
|
+
/**
|
|
234
|
+
* Scrolls to a specific index in the list.
|
|
235
|
+
* Supports viewPosition and viewOffset for precise positioning.
|
|
236
|
+
* Returns a Promise that resolves when the scroll is complete.
|
|
237
|
+
*/
|
|
238
|
+
scrollToIndex: ({ index, animated, viewPosition, viewOffset, }) => {
|
|
239
|
+
return new Promise((resolve) => {
|
|
240
|
+
const { horizontal } = recyclerViewManager.props;
|
|
241
|
+
if (scrollViewRef.current &&
|
|
242
|
+
index >= 0 &&
|
|
243
|
+
index < recyclerViewManager.getDataLength()) {
|
|
244
|
+
// Pause the scroll offset adjustments
|
|
245
|
+
pauseOffsetCorrection.current = true;
|
|
246
|
+
recyclerViewManager.setOffsetProjectionEnabled(false);
|
|
247
|
+
const getFinalOffset = () => {
|
|
248
|
+
const layout = recyclerViewManager.getLayout(index);
|
|
249
|
+
const offset = horizontal ? layout.x : layout.y;
|
|
250
|
+
let finalOffset = offset;
|
|
251
|
+
// take viewPosition etc into account
|
|
252
|
+
if (viewPosition !== undefined || viewOffset !== undefined) {
|
|
253
|
+
const containerSize = horizontal
|
|
254
|
+
? recyclerViewManager.getWindowSize().width
|
|
255
|
+
: recyclerViewManager.getWindowSize().height;
|
|
256
|
+
const itemSize = horizontal ? layout.width : layout.height;
|
|
257
|
+
if (viewPosition !== undefined) {
|
|
258
|
+
// viewPosition: 0 = top, 0.5 = center, 1 = bottom
|
|
259
|
+
finalOffset =
|
|
260
|
+
offset - (containerSize - itemSize) * viewPosition;
|
|
261
|
+
}
|
|
262
|
+
if (viewOffset !== undefined) {
|
|
263
|
+
finalOffset += viewOffset;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
return finalOffset + recyclerViewManager.firstItemOffset;
|
|
267
|
+
};
|
|
268
|
+
const lastAbsoluteScrollOffset = recyclerViewManager.getAbsoluteLastScrollOffset();
|
|
269
|
+
const bufferForScroll = horizontal
|
|
270
|
+
? recyclerViewManager.getWindowSize().width
|
|
271
|
+
: recyclerViewManager.getWindowSize().height;
|
|
272
|
+
const bufferForCompute = bufferForScroll * 2;
|
|
273
|
+
const getStartScrollOffset = () => {
|
|
274
|
+
let lastScrollOffset = lastAbsoluteScrollOffset;
|
|
275
|
+
const finalOffset = getFinalOffset();
|
|
276
|
+
if (finalOffset > lastScrollOffset) {
|
|
277
|
+
lastScrollOffset = Math.max(finalOffset - bufferForCompute, lastScrollOffset);
|
|
278
|
+
recyclerViewManager.setScrollDirection("forward");
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
lastScrollOffset = Math.min(finalOffset + bufferForCompute, lastScrollOffset);
|
|
282
|
+
recyclerViewManager.setScrollDirection("backward");
|
|
283
|
+
}
|
|
284
|
+
return lastScrollOffset;
|
|
285
|
+
};
|
|
286
|
+
let initialTargetOffset = getFinalOffset();
|
|
287
|
+
let initialStartScrollOffset = getStartScrollOffset();
|
|
288
|
+
let finalOffset = initialTargetOffset;
|
|
289
|
+
let startScrollOffset = initialStartScrollOffset;
|
|
290
|
+
const steps = 5;
|
|
291
|
+
/**
|
|
292
|
+
* Recursively performs the scroll animation steps.
|
|
293
|
+
* This function replaces the async/await loop with callback-based execution.
|
|
294
|
+
*
|
|
295
|
+
* @param currentStep - The current step in the animation (0 to steps-1)
|
|
296
|
+
*/
|
|
297
|
+
const performScrollStep = (currentStep) => {
|
|
298
|
+
// Check if component is unmounted or we've completed all steps
|
|
299
|
+
if (isUnmounted.current) {
|
|
300
|
+
resolve();
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
else if (currentStep >= steps) {
|
|
304
|
+
// All steps completed, perform final scroll
|
|
305
|
+
finishScrollToIndex();
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
// Calculate the offset for this step
|
|
309
|
+
// For animated scrolls: interpolate from finalOffset to startScrollOffset
|
|
310
|
+
// For non-animated: interpolate from startScrollOffset to finalOffset
|
|
311
|
+
const nextOffset = animated
|
|
312
|
+
? finalOffset +
|
|
313
|
+
(startScrollOffset - finalOffset) *
|
|
314
|
+
(currentStep / (steps - 1))
|
|
315
|
+
: startScrollOffset +
|
|
316
|
+
(finalOffset - startScrollOffset) *
|
|
317
|
+
(currentStep / (steps - 1));
|
|
318
|
+
// Update scroll offset with a callback to continue to the next step
|
|
319
|
+
updateScrollOffsetWithCallback(nextOffset, () => {
|
|
320
|
+
// Check if the index is still valid after the update
|
|
321
|
+
if (index >= recyclerViewManager.getDataLength()) {
|
|
322
|
+
// Index out of bounds, scroll to end instead
|
|
323
|
+
handlerMethods.scrollToEnd({ animated });
|
|
324
|
+
resolve(); // Resolve the promise as we're done
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
// Check if the target position has changed significantly
|
|
328
|
+
const newFinalOffset = getFinalOffset();
|
|
329
|
+
if ((newFinalOffset < initialTargetOffset &&
|
|
330
|
+
newFinalOffset < initialStartScrollOffset) ||
|
|
331
|
+
(newFinalOffset > initialTargetOffset &&
|
|
332
|
+
newFinalOffset > initialStartScrollOffset)) {
|
|
333
|
+
// Target has moved, recalculate and restart from beginning
|
|
334
|
+
finalOffset = newFinalOffset;
|
|
335
|
+
startScrollOffset = getStartScrollOffset();
|
|
336
|
+
initialTargetOffset = newFinalOffset;
|
|
337
|
+
initialStartScrollOffset = startScrollOffset;
|
|
338
|
+
performScrollStep(0); // Restart from step 0
|
|
339
|
+
}
|
|
340
|
+
else {
|
|
341
|
+
// Continue to next step
|
|
342
|
+
performScrollStep(currentStep + 1);
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
};
|
|
346
|
+
/**
|
|
347
|
+
* Completes the scroll to index operation by performing the final scroll
|
|
348
|
+
* and re-enabling offset correction after a delay.
|
|
349
|
+
*/
|
|
350
|
+
const finishScrollToIndex = () => {
|
|
351
|
+
finalOffset = getFinalOffset();
|
|
352
|
+
const maxOffset = recyclerViewManager.getMaxScrollOffset();
|
|
353
|
+
if (finalOffset > maxOffset) {
|
|
354
|
+
finalOffset = maxOffset;
|
|
355
|
+
}
|
|
356
|
+
if (animated) {
|
|
357
|
+
// For animated scrolls, first jump to the start position
|
|
358
|
+
// We don't need to add firstItemOffset here as it's already added
|
|
359
|
+
handlerMethods.scrollToOffset({
|
|
360
|
+
offset: startScrollOffset,
|
|
361
|
+
animated: false,
|
|
362
|
+
skipFirstItemOffset: true,
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
// Perform the final scroll to the target position
|
|
366
|
+
handlerMethods.scrollToOffset({
|
|
367
|
+
offset: finalOffset,
|
|
368
|
+
animated,
|
|
369
|
+
skipFirstItemOffset: true,
|
|
370
|
+
});
|
|
371
|
+
// Re-enable offset correction after a delay
|
|
372
|
+
// Longer delay for animated scrolls to allow animation to complete
|
|
373
|
+
setTimeout(() => {
|
|
374
|
+
pauseOffsetCorrection.current = false;
|
|
375
|
+
recyclerViewManager.setOffsetProjectionEnabled(true);
|
|
376
|
+
resolve(); // Resolve the promise after re-enabling corrections
|
|
377
|
+
}, animated ? 300 : 200);
|
|
378
|
+
};
|
|
379
|
+
// Start the scroll animation process
|
|
380
|
+
performScrollStep(0);
|
|
381
|
+
}
|
|
382
|
+
else {
|
|
383
|
+
// Invalid parameters, resolve immediately
|
|
384
|
+
resolve();
|
|
385
|
+
}
|
|
386
|
+
});
|
|
387
|
+
},
|
|
388
|
+
/**
|
|
389
|
+
* Scrolls to a specific item in the list.
|
|
390
|
+
* Finds the item's index and uses scrollToIndex internally.
|
|
391
|
+
*/
|
|
392
|
+
scrollToItem: ({ item, animated, viewPosition, viewOffset, }) => {
|
|
393
|
+
const { data } = recyclerViewManager.props;
|
|
394
|
+
if (scrollViewRef.current && data) {
|
|
395
|
+
// Find the index of the item in the data array
|
|
396
|
+
const index = data.findIndex((dataItem) => dataItem === item);
|
|
397
|
+
if (index >= 0) {
|
|
398
|
+
handlerMethods.scrollToIndex({
|
|
399
|
+
index,
|
|
400
|
+
animated,
|
|
401
|
+
viewPosition,
|
|
402
|
+
viewOffset,
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
},
|
|
407
|
+
// Utility methods for measuring header height / top padding
|
|
408
|
+
getFirstItemOffset: () => {
|
|
409
|
+
return recyclerViewManager.firstItemOffset;
|
|
410
|
+
},
|
|
411
|
+
getWindowSize: () => {
|
|
412
|
+
return recyclerViewManager.getWindowSize();
|
|
413
|
+
},
|
|
414
|
+
getLayout: (index) => {
|
|
415
|
+
return recyclerViewManager.tryGetLayout(index);
|
|
416
|
+
},
|
|
417
|
+
getAbsoluteLastScrollOffset: () => {
|
|
418
|
+
return recyclerViewManager.getAbsoluteLastScrollOffset();
|
|
419
|
+
},
|
|
420
|
+
getChildContainerDimensions: () => {
|
|
421
|
+
return recyclerViewManager.getChildContainerDimensions();
|
|
422
|
+
},
|
|
423
|
+
recordInteraction: () => {
|
|
424
|
+
recyclerViewManager.recordInteraction();
|
|
425
|
+
},
|
|
426
|
+
computeVisibleIndices: () => {
|
|
427
|
+
return recyclerViewManager.computeVisibleIndices();
|
|
428
|
+
},
|
|
429
|
+
getFirstVisibleIndex: () => {
|
|
430
|
+
return recyclerViewManager.computeVisibleIndices().startIndex;
|
|
431
|
+
},
|
|
432
|
+
recomputeViewableItems: () => {
|
|
433
|
+
recyclerViewManager.recomputeViewableItems();
|
|
434
|
+
},
|
|
435
|
+
/**
|
|
436
|
+
* Disables item recycling in preparation for layout animations.
|
|
437
|
+
*/
|
|
438
|
+
prepareForLayoutAnimationRender: () => {
|
|
439
|
+
if (!recyclerViewManager.props.keyExtractor) {
|
|
440
|
+
console.warn(WarningMessages.keyExtractorNotDefinedForAnimation);
|
|
441
|
+
}
|
|
442
|
+
recyclerViewManager.animationOptimizationsEnabled = true;
|
|
443
|
+
},
|
|
444
|
+
};
|
|
445
|
+
}, [
|
|
446
|
+
recyclerViewManager,
|
|
447
|
+
scrollViewRef,
|
|
448
|
+
setTimeout,
|
|
449
|
+
isUnmounted,
|
|
450
|
+
updateScrollOffsetWithCallback,
|
|
451
|
+
]);
|
|
452
|
+
const applyInitialScrollIndex = useCallback(() => {
|
|
453
|
+
var _a, _b, _c;
|
|
454
|
+
const { horizontal, data, initialScrollIndexParams } = recyclerViewManager.props;
|
|
455
|
+
const initialScrollIndex = (_a = recyclerViewManager.getInitialScrollIndex()) !== null && _a !== void 0 ? _a : -1;
|
|
456
|
+
const dataLength = (_b = data === null || data === void 0 ? void 0 : data.length) !== null && _b !== void 0 ? _b : 0;
|
|
457
|
+
if (initialScrollIndex >= 0 &&
|
|
458
|
+
initialScrollIndex < dataLength &&
|
|
459
|
+
!initialScrollCompletedRef.current &&
|
|
460
|
+
recyclerViewManager.getIsFirstLayoutComplete()) {
|
|
461
|
+
// Use setTimeout to ensure that we keep trying to scroll on first few renders
|
|
462
|
+
setTimeout(() => {
|
|
463
|
+
initialScrollCompletedRef.current = true;
|
|
464
|
+
pauseOffsetCorrection.current = false;
|
|
465
|
+
}, 100);
|
|
466
|
+
pauseOffsetCorrection.current = true;
|
|
467
|
+
const additionalOffset = (_c = initialScrollIndexParams === null || initialScrollIndexParams === void 0 ? void 0 : initialScrollIndexParams.viewOffset) !== null && _c !== void 0 ? _c : 0;
|
|
468
|
+
const offset = horizontal
|
|
469
|
+
? recyclerViewManager.getLayout(initialScrollIndex).x + additionalOffset
|
|
470
|
+
: recyclerViewManager.getLayout(initialScrollIndex).y +
|
|
471
|
+
additionalOffset;
|
|
472
|
+
handlerMethods.scrollToOffset({
|
|
473
|
+
offset,
|
|
474
|
+
animated: false,
|
|
475
|
+
skipFirstItemOffset: false,
|
|
476
|
+
});
|
|
477
|
+
setTimeout(() => {
|
|
478
|
+
handlerMethods.scrollToOffset({
|
|
479
|
+
offset,
|
|
480
|
+
animated: false,
|
|
481
|
+
skipFirstItemOffset: false,
|
|
482
|
+
});
|
|
483
|
+
}, 0);
|
|
484
|
+
}
|
|
485
|
+
}, [handlerMethods, recyclerViewManager, setTimeout]);
|
|
486
|
+
// Expose imperative methods through the ref
|
|
487
|
+
useImperativeHandle(ref, () => {
|
|
488
|
+
const imperativeApi = { ...scrollViewRef.current, ...handlerMethods };
|
|
489
|
+
// Without this the props getter from handlerMethods is evaluated during spread and
|
|
490
|
+
// future updates to props are not reflected in the ref
|
|
491
|
+
Object.defineProperty(imperativeApi, "props", {
|
|
492
|
+
get() {
|
|
493
|
+
return recyclerViewManager.props;
|
|
494
|
+
},
|
|
495
|
+
enumerable: true,
|
|
496
|
+
configurable: true,
|
|
497
|
+
});
|
|
498
|
+
return imperativeApi;
|
|
499
|
+
}, [handlerMethods, scrollViewRef, recyclerViewManager]);
|
|
500
|
+
return {
|
|
501
|
+
applyOffsetCorrection,
|
|
502
|
+
computeFirstVisibleIndexForOffsetCorrection,
|
|
503
|
+
applyInitialScrollIndex,
|
|
504
|
+
handlerMethods,
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
//# sourceMappingURL=useRecyclerViewController.js.map
|