react-native-reanimated-carousel 5.0.0-beta.7 → 5.0.0
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/README.md +60 -28
- package/lib/commonjs/components/Carousel.js +1 -1
- package/lib/commonjs/components/Carousel.js.map +1 -1
- package/lib/commonjs/components/CarouselLayout.js +1 -1
- package/lib/commonjs/components/CarouselLayout.js.map +1 -1
- package/lib/commonjs/components/ItemLayout.js +1 -1
- package/lib/commonjs/components/ItemLayout.js.map +1 -1
- package/lib/commonjs/components/ItemRenderer.js +1 -1
- package/lib/commonjs/components/ItemRenderer.js.map +1 -1
- package/lib/commonjs/components/Pagination/PaginationItem.js +2 -0
- package/lib/commonjs/components/Pagination/PaginationItem.js.map +1 -0
- package/lib/commonjs/components/Pagination/index.js +1 -1
- package/lib/commonjs/components/Pagination/index.js.map +1 -1
- package/lib/commonjs/components/ScrollViewGesture.js +1 -1
- package/lib/commonjs/components/ScrollViewGesture.js.map +1 -1
- package/lib/commonjs/hooks/useAutoPlay.js +1 -1
- package/lib/commonjs/hooks/useAutoPlay.js.map +1 -1
- package/lib/commonjs/hooks/useCarouselController.js +1 -1
- package/lib/commonjs/hooks/useCarouselController.js.map +1 -1
- package/lib/commonjs/hooks/useCommonVariables.js +1 -1
- package/lib/commonjs/hooks/useCommonVariables.js.map +1 -1
- package/lib/commonjs/hooks/useInitProps.js +1 -1
- package/lib/commonjs/hooks/useInitProps.js.map +1 -1
- package/lib/commonjs/hooks/useLayoutConfig.js +1 -1
- package/lib/commonjs/hooks/useLayoutConfig.js.map +1 -1
- package/lib/commonjs/hooks/useOffsetX.js.map +1 -1
- package/lib/commonjs/hooks/useOnProgressChange.js +1 -1
- package/lib/commonjs/hooks/useOnProgressChange.js.map +1 -1
- package/lib/commonjs/hooks/usePanGestureProxy.js.map +1 -1
- package/lib/commonjs/hooks/usePropsErrorBoundary.js +1 -1
- package/lib/commonjs/hooks/usePropsErrorBoundary.js.map +1 -1
- package/lib/commonjs/hooks/useUpdateGestureConfig.js.map +1 -1
- package/lib/commonjs/hooks/useVisibleRanges.js.map +1 -1
- package/lib/commonjs/index.js +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/layouts/index.js.map +1 -1
- package/lib/commonjs/layouts/normal.js +1 -1
- package/lib/commonjs/layouts/normal.js.map +1 -1
- package/lib/commonjs/layouts/parallax.js +1 -1
- package/lib/commonjs/layouts/parallax.js.map +1 -1
- package/lib/commonjs/layouts/stack.js +1 -1
- package/lib/commonjs/layouts/stack.js.map +1 -1
- package/lib/commonjs/public-types.js +2 -0
- package/lib/commonjs/public-types.js.map +1 -0
- package/lib/commonjs/store/index.js.map +1 -1
- package/lib/commonjs/utils/carousel-direction.js +2 -0
- package/lib/commonjs/utils/carousel-direction.js.map +1 -0
- package/lib/commonjs/utils/carousel-math.js +2 -0
- package/lib/commonjs/utils/carousel-math.js.map +1 -0
- package/lib/commonjs/utils/deal-with-animation.js +1 -1
- package/lib/commonjs/utils/deal-with-animation.js.map +1 -1
- package/lib/module/components/Carousel.js +1 -1
- package/lib/module/components/Carousel.js.map +1 -1
- package/lib/module/components/CarouselLayout.js +1 -1
- package/lib/module/components/CarouselLayout.js.map +1 -1
- package/lib/module/components/ItemLayout.js +1 -1
- package/lib/module/components/ItemLayout.js.map +1 -1
- package/lib/module/components/ItemRenderer.js +1 -1
- package/lib/module/components/ItemRenderer.js.map +1 -1
- package/lib/module/components/LazyView.js +1 -1
- package/lib/module/components/LazyView.js.map +1 -1
- package/lib/module/components/Pagination/PaginationItem.js +2 -0
- package/lib/module/components/Pagination/PaginationItem.js.map +1 -0
- package/lib/module/components/Pagination/index.js +1 -1
- package/lib/module/components/Pagination/index.js.map +1 -1
- package/lib/module/components/ScrollViewGesture.js +1 -1
- package/lib/module/components/ScrollViewGesture.js.map +1 -1
- package/lib/module/constants/index.js +1 -1
- package/lib/module/constants/index.js.map +1 -1
- package/lib/module/hooks/useAutoPlay.js +1 -1
- package/lib/module/hooks/useAutoPlay.js.map +1 -1
- package/lib/module/hooks/useCarouselController.js +1 -1
- package/lib/module/hooks/useCarouselController.js.map +1 -1
- package/lib/module/hooks/useCheckMounted.js +1 -1
- package/lib/module/hooks/useCheckMounted.js.map +1 -1
- package/lib/module/hooks/useCommonVariables.js +1 -1
- package/lib/module/hooks/useCommonVariables.js.map +1 -1
- package/lib/module/hooks/useInitProps.js +1 -1
- package/lib/module/hooks/useInitProps.js.map +1 -1
- package/lib/module/hooks/useLayoutConfig.js +1 -1
- package/lib/module/hooks/useLayoutConfig.js.map +1 -1
- package/lib/module/hooks/useOffsetX.js +1 -1
- package/lib/module/hooks/useOffsetX.js.map +1 -1
- package/lib/module/hooks/useOnProgressChange.js +1 -1
- package/lib/module/hooks/useOnProgressChange.js.map +1 -1
- package/lib/module/hooks/usePanGestureProxy.js +1 -1
- package/lib/module/hooks/usePanGestureProxy.js.map +1 -1
- package/lib/module/hooks/usePropsErrorBoundary.js +1 -1
- package/lib/module/hooks/usePropsErrorBoundary.js.map +1 -1
- package/lib/module/hooks/useUpdateGestureConfig.js +1 -1
- package/lib/module/hooks/useUpdateGestureConfig.js.map +1 -1
- package/lib/module/hooks/useVisibleRanges.js +1 -1
- package/lib/module/hooks/useVisibleRanges.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/layouts/index.js +1 -1
- package/lib/module/layouts/index.js.map +1 -1
- package/lib/module/layouts/normal.js +1 -1
- package/lib/module/layouts/normal.js.map +1 -1
- package/lib/module/layouts/parallax.js +1 -1
- package/lib/module/layouts/parallax.js.map +1 -1
- package/lib/module/layouts/stack.js +1 -1
- package/lib/module/layouts/stack.js.map +1 -1
- package/lib/module/package.json +1 -0
- package/lib/module/public-types.js +2 -0
- package/lib/module/public-types.js.map +1 -0
- package/lib/module/store/index.js +1 -1
- package/lib/module/store/index.js.map +1 -1
- package/lib/module/types.js +1 -1
- package/lib/module/utils/carousel-direction.js +2 -0
- package/lib/module/utils/carousel-direction.js.map +1 -0
- package/lib/module/utils/carousel-math.js +2 -0
- package/lib/module/utils/carousel-math.js.map +1 -0
- package/lib/module/utils/compute-gesture-translation.js +1 -1
- package/lib/module/utils/compute-gesture-translation.js.map +1 -1
- package/lib/module/utils/compute-offset-if-size-changed.js +1 -1
- package/lib/module/utils/compute-offset-if-size-changed.js.map +1 -1
- package/lib/module/utils/computed-with-auto-fill-data.js +1 -1
- package/lib/module/utils/computed-with-auto-fill-data.js.map +1 -1
- package/lib/module/utils/deal-with-animation.js +1 -1
- package/lib/module/utils/deal-with-animation.js.map +1 -1
- package/lib/module/utils/log.js +1 -1
- package/lib/module/utils/log.js.map +1 -1
- package/lib/module/utils/sanitize-animation-style.js +1 -1
- package/lib/module/utils/sanitize-animation-style.js.map +1 -1
- package/lib/typescript/commonjs/components/Carousel.d.ts +8 -0
- package/lib/typescript/commonjs/components/Carousel.d.ts.map +1 -0
- package/lib/typescript/{components → commonjs/components}/CarouselLayout.d.ts +5 -8
- package/lib/typescript/commonjs/components/CarouselLayout.d.ts.map +1 -0
- package/lib/typescript/{components → commonjs/components}/ItemLayout.d.ts +7 -6
- package/lib/typescript/commonjs/components/ItemLayout.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/ItemRenderer.d.ts +24 -0
- package/lib/typescript/commonjs/components/ItemRenderer.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/LazyView.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/Pagination/PaginationItem.d.ts +14 -0
- package/lib/typescript/commonjs/components/Pagination/PaginationItem.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/Pagination/index.d.ts +4 -0
- package/lib/typescript/commonjs/components/Pagination/index.d.ts.map +1 -0
- package/lib/typescript/{components → commonjs/components}/ScrollViewGesture.d.ts +3 -4
- package/lib/typescript/commonjs/components/ScrollViewGesture.d.ts.map +1 -0
- package/lib/typescript/commonjs/constants/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks/useAutoPlay.d.ts +12 -0
- package/lib/typescript/commonjs/hooks/useAutoPlay.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks/useCarouselController.d.ts +29 -0
- package/lib/typescript/commonjs/hooks/useCarouselController.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks/useCheckMounted.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks/useCommonVariables.d.ts +18 -0
- package/lib/typescript/commonjs/hooks/useCommonVariables.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks/useInitProps.d.ts +25 -0
- package/lib/typescript/commonjs/hooks/useInitProps.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks/useLayoutConfig.d.ts +8 -0
- package/lib/typescript/commonjs/hooks/useLayoutConfig.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks/useOffsetX.d.ts +13 -0
- package/lib/typescript/commonjs/hooks/useOffsetX.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks/useOnProgressChange.d.ts +12 -0
- package/lib/typescript/commonjs/hooks/useOnProgressChange.d.ts.map +1 -0
- package/lib/typescript/{hooks → commonjs/hooks}/usePanGestureProxy.d.ts +3 -2
- package/lib/typescript/commonjs/hooks/usePanGestureProxy.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks/usePropsErrorBoundary.d.ts +3 -0
- package/lib/typescript/commonjs/hooks/usePropsErrorBoundary.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks/useUpdateGestureConfig.d.ts +9 -0
- package/lib/typescript/commonjs/hooks/useUpdateGestureConfig.d.ts.map +1 -0
- package/lib/typescript/{hooks → commonjs/hooks}/useVisibleRanges.d.ts +2 -2
- package/lib/typescript/commonjs/hooks/useVisibleRanges.d.ts.map +1 -0
- package/lib/typescript/commonjs/index.d.ts +4 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -0
- package/lib/typescript/{layouts → commonjs/layouts}/index.d.ts +0 -1
- package/lib/typescript/commonjs/layouts/index.d.ts.map +1 -0
- package/lib/typescript/{layouts → commonjs/layouts}/normal.d.ts +3 -1
- package/lib/typescript/commonjs/layouts/normal.d.ts.map +1 -0
- package/lib/typescript/commonjs/layouts/parallax.d.ts +27 -0
- package/lib/typescript/commonjs/layouts/parallax.d.ts.map +1 -0
- package/lib/typescript/commonjs/layouts/stack.d.ts +10 -0
- package/lib/typescript/commonjs/layouts/stack.d.ts.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/public-types.d.ts +161 -0
- package/lib/typescript/commonjs/public-types.d.ts.map +1 -0
- package/lib/typescript/{store → commonjs/store}/index.d.ts +8 -8
- package/lib/typescript/commonjs/store/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/types.d.ts +15 -0
- package/lib/typescript/commonjs/types.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils/carousel-direction.d.ts +9 -0
- package/lib/typescript/commonjs/utils/carousel-direction.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils/carousel-math.d.ts +28 -0
- package/lib/typescript/commonjs/utils/carousel-math.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils/compute-gesture-translation.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils/compute-offset-if-size-changed.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils/computed-with-auto-fill-data.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils/deal-with-animation.d.ts +3 -0
- package/lib/typescript/commonjs/utils/deal-with-animation.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils/log.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils/sanitize-animation-style.d.ts.map +1 -0
- package/lib/typescript/module/components/Carousel.d.ts +8 -0
- package/lib/typescript/module/components/Carousel.d.ts.map +1 -0
- package/lib/typescript/module/components/CarouselLayout.d.ts +14 -0
- package/lib/typescript/module/components/CarouselLayout.d.ts.map +1 -0
- package/lib/typescript/module/components/ItemLayout.d.ts +21 -0
- package/lib/typescript/module/components/ItemLayout.d.ts.map +1 -0
- package/lib/typescript/module/components/ItemRenderer.d.ts +24 -0
- package/lib/typescript/module/components/ItemRenderer.d.ts.map +1 -0
- package/lib/typescript/module/components/LazyView.d.ts +8 -0
- package/lib/typescript/module/components/LazyView.d.ts.map +1 -0
- package/lib/typescript/module/components/Pagination/PaginationItem.d.ts +14 -0
- package/lib/typescript/module/components/Pagination/PaginationItem.d.ts.map +1 -0
- package/lib/typescript/module/components/Pagination/index.d.ts +4 -0
- package/lib/typescript/module/components/Pagination/index.d.ts.map +1 -0
- package/lib/typescript/module/components/ScrollViewGesture.d.ts +18 -0
- package/lib/typescript/module/components/ScrollViewGesture.d.ts.map +1 -0
- package/lib/typescript/module/constants/index.d.ts +9 -0
- package/lib/typescript/module/constants/index.d.ts.map +1 -0
- package/lib/typescript/module/hooks/useAutoPlay.d.ts +12 -0
- package/lib/typescript/module/hooks/useAutoPlay.d.ts.map +1 -0
- package/lib/typescript/module/hooks/useCarouselController.d.ts +29 -0
- package/lib/typescript/module/hooks/useCarouselController.d.ts.map +1 -0
- package/lib/typescript/module/hooks/useCheckMounted.d.ts +3 -0
- package/lib/typescript/module/hooks/useCheckMounted.d.ts.map +1 -0
- package/lib/typescript/module/hooks/useCommonVariables.d.ts +18 -0
- package/lib/typescript/module/hooks/useCommonVariables.d.ts.map +1 -0
- package/lib/typescript/module/hooks/useInitProps.d.ts +25 -0
- package/lib/typescript/module/hooks/useInitProps.d.ts.map +1 -0
- package/lib/typescript/module/hooks/useLayoutConfig.d.ts +8 -0
- package/lib/typescript/module/hooks/useLayoutConfig.d.ts.map +1 -0
- package/lib/typescript/module/hooks/useOffsetX.d.ts +13 -0
- package/lib/typescript/module/hooks/useOffsetX.d.ts.map +1 -0
- package/lib/typescript/module/hooks/useOnProgressChange.d.ts +12 -0
- package/lib/typescript/module/hooks/useOnProgressChange.d.ts.map +1 -0
- package/lib/typescript/module/hooks/usePanGestureProxy.d.ts +11 -0
- package/lib/typescript/module/hooks/usePanGestureProxy.d.ts.map +1 -0
- package/lib/typescript/module/hooks/usePropsErrorBoundary.d.ts +3 -0
- package/lib/typescript/module/hooks/usePropsErrorBoundary.d.ts.map +1 -0
- package/lib/typescript/module/hooks/useUpdateGestureConfig.d.ts +9 -0
- package/lib/typescript/module/hooks/useUpdateGestureConfig.d.ts.map +1 -0
- package/lib/typescript/module/hooks/useVisibleRanges.d.ts +22 -0
- package/lib/typescript/module/hooks/useVisibleRanges.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +4 -0
- package/lib/typescript/module/index.d.ts.map +1 -0
- package/lib/typescript/module/layouts/index.d.ts +10 -0
- package/lib/typescript/module/layouts/index.d.ts.map +1 -0
- package/lib/typescript/module/layouts/normal.d.ts +15 -0
- package/lib/typescript/module/layouts/normal.d.ts.map +1 -0
- package/lib/typescript/module/layouts/parallax.d.ts +27 -0
- package/lib/typescript/module/layouts/parallax.d.ts.map +1 -0
- package/lib/typescript/module/layouts/stack.d.ts +10 -0
- package/lib/typescript/module/layouts/stack.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/public-types.d.ts +161 -0
- package/lib/typescript/module/public-types.d.ts.map +1 -0
- package/lib/typescript/module/store/index.d.ts +35 -0
- package/lib/typescript/module/store/index.d.ts.map +1 -0
- package/lib/typescript/module/types.d.ts +15 -0
- package/lib/typescript/module/types.d.ts.map +1 -0
- package/lib/typescript/module/utils/carousel-direction.d.ts +9 -0
- package/lib/typescript/module/utils/carousel-direction.d.ts.map +1 -0
- package/lib/typescript/module/utils/carousel-math.d.ts +28 -0
- package/lib/typescript/module/utils/carousel-math.d.ts.map +1 -0
- package/lib/typescript/module/utils/compute-gesture-translation.d.ts +9 -0
- package/lib/typescript/module/utils/compute-gesture-translation.d.ts.map +1 -0
- package/lib/typescript/module/utils/compute-offset-if-size-changed.d.ts +6 -0
- package/lib/typescript/module/utils/compute-offset-if-size-changed.d.ts.map +1 -0
- package/lib/typescript/module/utils/computed-with-auto-fill-data.d.ts +23 -0
- package/lib/typescript/module/utils/computed-with-auto-fill-data.d.ts.map +1 -0
- package/lib/typescript/module/utils/deal-with-animation.d.ts +3 -0
- package/lib/typescript/module/utils/deal-with-animation.d.ts.map +1 -0
- package/lib/typescript/module/utils/log.d.ts +7 -0
- package/lib/typescript/module/utils/log.d.ts.map +1 -0
- package/lib/typescript/module/utils/sanitize-animation-style.d.ts +3 -0
- package/lib/typescript/module/utils/sanitize-animation-style.d.ts.map +1 -0
- package/package.json +34 -7
- package/scripts/codemods/v5.mjs +502 -0
- package/src/components/Carousel.tsx +5 -5
- package/src/components/CarouselLayout.tsx +53 -91
- package/src/components/ItemLayout.tsx +55 -46
- package/src/components/ItemRenderer.tsx +29 -18
- package/src/components/Pagination/PaginationItem.tsx +162 -0
- package/src/components/Pagination/index.tsx +105 -6
- package/src/components/ScrollViewGesture.tsx +92 -177
- package/src/hooks/useAutoPlay.ts +23 -18
- package/src/hooks/useCarouselController.tsx +194 -340
- package/src/hooks/useCommonVariables.ts +159 -71
- package/src/hooks/useInitProps.ts +161 -71
- package/src/hooks/useLayoutConfig.ts +21 -12
- package/src/hooks/useOffsetX.ts +3 -3
- package/src/hooks/useOnProgressChange.ts +23 -48
- package/src/hooks/usePanGestureProxy.ts +2 -2
- package/src/hooks/usePropsErrorBoundary.ts +32 -90
- package/src/hooks/useUpdateGestureConfig.ts +5 -2
- package/src/hooks/useVisibleRanges.tsx +2 -2
- package/src/index.tsx +14 -9
- package/src/layouts/index.tsx +0 -2
- package/src/layouts/normal.ts +14 -4
- package/src/layouts/parallax.ts +32 -59
- package/src/layouts/stack.ts +30 -70
- package/src/public-types.ts +198 -0
- package/src/store/index.tsx +7 -7
- package/src/types.ts +30 -322
- package/src/utils/carousel-direction.ts +39 -0
- package/src/utils/carousel-math.ts +156 -0
- package/src/utils/deal-with-animation.ts +11 -9
- package/lib/commonjs/components/Pagination/Basic/PaginationItem.js +0 -2
- package/lib/commonjs/components/Pagination/Basic/PaginationItem.js.map +0 -1
- package/lib/commonjs/components/Pagination/Basic/index.js +0 -2
- package/lib/commonjs/components/Pagination/Basic/index.js.map +0 -1
- package/lib/commonjs/components/Pagination/Custom/PaginationItem.js +0 -2
- package/lib/commonjs/components/Pagination/Custom/PaginationItem.js.map +0 -1
- package/lib/commonjs/components/Pagination/Custom/index.js +0 -2
- package/lib/commonjs/components/Pagination/Custom/index.js.map +0 -1
- package/lib/commonjs/utils/compute-offset-if-data-changed.js +0 -2
- package/lib/commonjs/utils/compute-offset-if-data-changed.js.map +0 -1
- package/lib/commonjs/utils/handleroffset-direction.js +0 -2
- package/lib/commonjs/utils/handleroffset-direction.js.map +0 -1
- package/lib/module/components/Pagination/Basic/PaginationItem.js +0 -2
- package/lib/module/components/Pagination/Basic/PaginationItem.js.map +0 -1
- package/lib/module/components/Pagination/Basic/index.js +0 -2
- package/lib/module/components/Pagination/Basic/index.js.map +0 -1
- package/lib/module/components/Pagination/Custom/PaginationItem.js +0 -2
- package/lib/module/components/Pagination/Custom/PaginationItem.js.map +0 -1
- package/lib/module/components/Pagination/Custom/index.js +0 -2
- package/lib/module/components/Pagination/Custom/index.js.map +0 -1
- package/lib/module/utils/compute-offset-if-data-changed.js +0 -2
- package/lib/module/utils/compute-offset-if-data-changed.js.map +0 -1
- package/lib/module/utils/handleroffset-direction.js +0 -2
- package/lib/module/utils/handleroffset-direction.js.map +0 -1
- package/lib/typescript/components/Carousel.d.ts +0 -8
- package/lib/typescript/components/Carousel.d.ts.map +0 -1
- package/lib/typescript/components/CarouselLayout.d.ts.map +0 -1
- package/lib/typescript/components/ItemLayout.d.ts.map +0 -1
- package/lib/typescript/components/ItemRenderer.d.ts +0 -23
- package/lib/typescript/components/ItemRenderer.d.ts.map +0 -1
- package/lib/typescript/components/LazyView.d.ts.map +0 -1
- package/lib/typescript/components/Pagination/Basic/PaginationItem.d.ts +0 -29
- package/lib/typescript/components/Pagination/Basic/PaginationItem.d.ts.map +0 -1
- package/lib/typescript/components/Pagination/Basic/index.d.ts +0 -23
- package/lib/typescript/components/Pagination/Basic/index.d.ts.map +0 -1
- package/lib/typescript/components/Pagination/Custom/PaginationItem.d.ts +0 -35
- package/lib/typescript/components/Pagination/Custom/PaginationItem.d.ts.map +0 -1
- package/lib/typescript/components/Pagination/Custom/index.d.ts +0 -26
- package/lib/typescript/components/Pagination/Custom/index.d.ts.map +0 -1
- package/lib/typescript/components/Pagination/index.d.ts +0 -5
- package/lib/typescript/components/Pagination/index.d.ts.map +0 -1
- package/lib/typescript/components/ScrollViewGesture.d.ts.map +0 -1
- package/lib/typescript/constants/index.d.ts.map +0 -1
- package/lib/typescript/hooks/useAutoPlay.d.ts +0 -12
- package/lib/typescript/hooks/useAutoPlay.d.ts.map +0 -1
- package/lib/typescript/hooks/useCarouselController.d.ts +0 -28
- package/lib/typescript/hooks/useCarouselController.d.ts.map +0 -1
- package/lib/typescript/hooks/useCheckMounted.d.ts.map +0 -1
- package/lib/typescript/hooks/useCommonVariables.d.ts +0 -13
- package/lib/typescript/hooks/useCommonVariables.d.ts.map +0 -1
- package/lib/typescript/hooks/useInitProps.d.ts +0 -10
- package/lib/typescript/hooks/useInitProps.d.ts.map +0 -1
- package/lib/typescript/hooks/useLayoutConfig.d.ts +0 -8
- package/lib/typescript/hooks/useLayoutConfig.d.ts.map +0 -1
- package/lib/typescript/hooks/useOffsetX.d.ts +0 -13
- package/lib/typescript/hooks/useOffsetX.d.ts.map +0 -1
- package/lib/typescript/hooks/useOnProgressChange.d.ts +0 -11
- package/lib/typescript/hooks/useOnProgressChange.d.ts.map +0 -1
- package/lib/typescript/hooks/usePanGestureProxy.d.ts.map +0 -1
- package/lib/typescript/hooks/usePropsErrorBoundary.d.ts +0 -5
- package/lib/typescript/hooks/usePropsErrorBoundary.d.ts.map +0 -1
- package/lib/typescript/hooks/useUpdateGestureConfig.d.ts +0 -6
- package/lib/typescript/hooks/useUpdateGestureConfig.d.ts.map +0 -1
- package/lib/typescript/hooks/useVisibleRanges.d.ts.map +0 -1
- package/lib/typescript/index.d.ts +0 -7
- package/lib/typescript/index.d.ts.map +0 -1
- package/lib/typescript/layouts/index.d.ts.map +0 -1
- package/lib/typescript/layouts/normal.d.ts.map +0 -1
- package/lib/typescript/layouts/parallax.d.ts +0 -47
- package/lib/typescript/layouts/parallax.d.ts.map +0 -1
- package/lib/typescript/layouts/stack.d.ts +0 -38
- package/lib/typescript/layouts/stack.d.ts.map +0 -1
- package/lib/typescript/store/index.d.ts.map +0 -1
- package/lib/typescript/types.d.ts +0 -302
- package/lib/typescript/types.d.ts.map +0 -1
- package/lib/typescript/utils/compute-gesture-translation.d.ts.map +0 -1
- package/lib/typescript/utils/compute-offset-if-data-changed.d.ts +0 -9
- package/lib/typescript/utils/compute-offset-if-data-changed.d.ts.map +0 -1
- package/lib/typescript/utils/compute-offset-if-size-changed.d.ts.map +0 -1
- package/lib/typescript/utils/computed-with-auto-fill-data.d.ts.map +0 -1
- package/lib/typescript/utils/deal-with-animation.d.ts +0 -3
- package/lib/typescript/utils/deal-with-animation.d.ts.map +0 -1
- package/lib/typescript/utils/handleroffset-direction.d.ts +0 -4
- package/lib/typescript/utils/handleroffset-direction.d.ts.map +0 -1
- package/lib/typescript/utils/log.d.ts.map +0 -1
- package/lib/typescript/utils/sanitize-animation-style.d.ts.map +0 -1
- package/src/components/Carousel.test.tsx +0 -1215
- package/src/components/LazyView.test.tsx +0 -61
- package/src/components/Pagination/Basic/PaginationItem.tsx +0 -149
- package/src/components/Pagination/Basic/index.tsx +0 -98
- package/src/components/Pagination/Custom/PaginationItem.tsx +0 -166
- package/src/components/Pagination/Custom/index.tsx +0 -111
- package/src/components/Pagination/Pagination.test.tsx +0 -178
- package/src/components/ScrollViewGesture.test.tsx +0 -155
- package/src/components/issue-899-parallax-reverse-loop.test.tsx +0 -131
- package/src/components/rnr-demo.test.tsx +0 -53
- package/src/hooks/useAutoPlay.test.ts +0 -194
- package/src/hooks/useCarouselController.test.tsx +0 -1158
- package/src/hooks/useCheckMounted.test.ts +0 -47
- package/src/hooks/useCommonVariables.test.tsx +0 -384
- package/src/hooks/useInitProps.test.tsx +0 -134
- package/src/hooks/useLayoutConfig.test.tsx +0 -247
- package/src/hooks/useOffsetX.test.ts +0 -54
- package/src/hooks/useOnProgressChange.test.tsx +0 -270
- package/src/hooks/usePanGestureProxy.test.tsx +0 -368
- package/src/hooks/usePropsErrorBoundary.test.tsx +0 -57
- package/src/hooks/useUpdateGestureConfig.test.ts +0 -89
- package/src/hooks/useVisibleRanges.test.tsx +0 -347
- package/src/layouts/parallax.test.ts +0 -239
- package/src/layouts/stack.test.ts +0 -252
- package/src/store/index.test.tsx +0 -314
- package/src/utils/compute-gesture-translation.test.ts +0 -70
- package/src/utils/compute-offset-if-data-changed.test.ts +0 -133
- package/src/utils/compute-offset-if-data-changed.ts +0 -44
- package/src/utils/compute-offset-if-size-changed.test.ts +0 -78
- package/src/utils/computed-with-auto-fill-data.test.ts +0 -298
- package/src/utils/deal-with-animation.test.ts +0 -181
- package/src/utils/handleroffset-direction.test.ts +0 -124
- package/src/utils/handleroffset-direction.ts +0 -18
- package/src/utils/index.test.ts +0 -90
- package/src/utils/log.test.ts +0 -134
- package/src/utils/sanitize-animation-style.test.ts +0 -40
- /package/lib/typescript/{components → commonjs/components}/LazyView.d.ts +0 -0
- /package/lib/typescript/{constants → commonjs/constants}/index.d.ts +0 -0
- /package/lib/typescript/{hooks → commonjs/hooks}/useCheckMounted.d.ts +0 -0
- /package/lib/typescript/{utils → commonjs/utils}/compute-gesture-translation.d.ts +0 -0
- /package/lib/typescript/{utils → commonjs/utils}/compute-offset-if-size-changed.d.ts +0 -0
- /package/lib/typescript/{utils → commonjs/utils}/computed-with-auto-fill-data.d.ts +0 -0
- /package/lib/typescript/{utils → commonjs/utils}/log.d.ts +0 -0
- /package/lib/typescript/{utils → commonjs/utils}/sanitize-animation-style.d.ts +0 -0
|
@@ -1,422 +1,273 @@
|
|
|
1
1
|
import React, { useRef } from "react";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import type { SharedValue } from "react-native-reanimated";
|
|
3
|
+
import { useAnimatedReaction, useSharedValue } from "react-native-reanimated";
|
|
4
4
|
import { scheduleOnRN } from "react-native-worklets";
|
|
5
5
|
|
|
6
|
-
import { Easing } from "../constants";
|
|
7
6
|
import { useGlobalState } from "../store";
|
|
8
7
|
import type {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
CarouselAnimation,
|
|
9
|
+
CarouselRef,
|
|
10
|
+
InternalCarouselScrollToOptions,
|
|
11
|
+
InternalCarouselStepOptions,
|
|
13
12
|
} from "../types";
|
|
14
13
|
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
getLogicalProgress,
|
|
15
|
+
getNearestLogicalPage,
|
|
16
|
+
getSettledRawIndex,
|
|
17
|
+
getShortestLoopTargetPage,
|
|
18
|
+
positiveModulo,
|
|
19
|
+
} from "../utils/carousel-math";
|
|
18
20
|
import { dealWithAnimation } from "../utils/deal-with-animation";
|
|
19
|
-
import { handlerOffsetDirection } from "../utils/handleroffset-direction";
|
|
20
|
-
import { round } from "../utils/log";
|
|
21
21
|
|
|
22
|
-
interface
|
|
23
|
-
ref: React.ForwardedRef<
|
|
22
|
+
interface CarouselControllerOptions {
|
|
23
|
+
ref: React.ForwardedRef<CarouselRef>;
|
|
24
24
|
loop: boolean;
|
|
25
25
|
size: number;
|
|
26
26
|
dataLength: number;
|
|
27
|
+
rawDataLength: number;
|
|
27
28
|
handlerOffset: SharedValue<number>;
|
|
28
|
-
|
|
29
|
-
withAnimation?: TCarouselProps["withAnimation"];
|
|
30
|
-
fixedDirection?: TCarouselProps["fixedDirection"];
|
|
31
|
-
duration?: number;
|
|
29
|
+
animation: CarouselAnimation;
|
|
32
30
|
defaultIndex?: number;
|
|
33
31
|
onScrollStart?: () => void;
|
|
34
|
-
|
|
32
|
+
onMovementEnd?: (index: number) => void;
|
|
35
33
|
}
|
|
36
34
|
|
|
37
|
-
export interface
|
|
35
|
+
export interface CarouselController {
|
|
38
36
|
getSharedIndex: () => number;
|
|
39
|
-
prev: (
|
|
40
|
-
next: (
|
|
37
|
+
prev: (options?: InternalCarouselStepOptions) => void;
|
|
38
|
+
next: (options?: InternalCarouselStepOptions) => void;
|
|
41
39
|
getCurrentIndex: () => number;
|
|
42
|
-
scrollTo: (
|
|
40
|
+
scrollTo: (options: InternalCarouselScrollToOptions) => void;
|
|
43
41
|
index: SharedValue<number>;
|
|
42
|
+
startMovement: () => void;
|
|
43
|
+
cancelMovement: () => void;
|
|
44
|
+
settle: () => number;
|
|
44
45
|
}
|
|
45
46
|
|
|
46
|
-
export function useCarouselController(options:
|
|
47
|
+
export function useCarouselController(options: CarouselControllerOptions): CarouselController {
|
|
47
48
|
const {
|
|
48
|
-
|
|
49
|
-
size,
|
|
50
|
-
loop,
|
|
49
|
+
animation,
|
|
51
50
|
dataLength,
|
|
52
|
-
handlerOffset,
|
|
53
|
-
withAnimation,
|
|
54
51
|
defaultIndex = 0,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
52
|
+
handlerOffset,
|
|
53
|
+
loop,
|
|
54
|
+
rawDataLength,
|
|
55
|
+
ref,
|
|
56
|
+
size,
|
|
58
57
|
} = options;
|
|
58
|
+
const {
|
|
59
|
+
common: {
|
|
60
|
+
cancelMovement: cancelCommonMovement,
|
|
61
|
+
dataRevision,
|
|
62
|
+
isMoving,
|
|
63
|
+
resolvedSize,
|
|
64
|
+
settleMovement,
|
|
65
|
+
sizePhase,
|
|
66
|
+
startMovement: startCommonMovement,
|
|
67
|
+
},
|
|
68
|
+
} = useGlobalState();
|
|
59
69
|
|
|
60
|
-
const
|
|
70
|
+
const index = useSharedValue(defaultIndex);
|
|
71
|
+
const liveRawIndex = useRef(rawDataLength > 0 ? defaultIndex : 0);
|
|
72
|
+
const settledIndex = useRef(rawDataLength > 0 ? defaultIndex : 0);
|
|
73
|
+
const warnedCommands = useRef(new Set<string>());
|
|
74
|
+
const canMove = rawDataLength > 1;
|
|
61
75
|
|
|
62
|
-
const {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
76
|
+
const warnOnce = React.useCallback((key: string, message: string) => {
|
|
77
|
+
if (!__DEV__ || warnedCommands.current.has(key)) return;
|
|
78
|
+
warnedCommands.current.add(key);
|
|
79
|
+
console.warn(`[react-native-reanimated-carousel] ${message}`);
|
|
80
|
+
}, []);
|
|
67
81
|
|
|
68
|
-
const
|
|
69
|
-
()
|
|
70
|
-
length: dataLength,
|
|
71
|
-
disable: !dataLength,
|
|
72
|
-
originalLength: dataLength,
|
|
73
|
-
}),
|
|
74
|
-
[dataLength]
|
|
75
|
-
);
|
|
82
|
+
const currentVisualPage = React.useCallback(() => {
|
|
83
|
+
if (size <= 0 || rawDataLength <= 0) return 0;
|
|
76
84
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (size <= 0) return 0;
|
|
84
|
-
if (loop) return -Math.round(handlerOffset.value / size);
|
|
85
|
-
|
|
86
|
-
// In non-loop mode, treat the offset as negative when moving forward.
|
|
87
|
-
// Clamp within valid range to avoid wrapping when a tiny positive offset
|
|
88
|
-
// appears after overscroll at index 0.
|
|
89
|
-
const rawPage = -handlerOffset.value / size;
|
|
90
|
-
const rounded = Math.round(rawPage);
|
|
91
|
-
const clamped = Math.max(0, Math.min(dataInfo.length - 1, rounded));
|
|
92
|
-
return clamped;
|
|
93
|
-
}, [handlerOffset, dataInfo, size, loop]);
|
|
94
|
-
|
|
95
|
-
function setSharedIndex(newSharedIndex: number) {
|
|
96
|
-
sharedIndex.current = newSharedIndex;
|
|
85
|
+
const page = getNearestLogicalPage(handlerOffset.value, size);
|
|
86
|
+
return loop ? page : Math.max(0, Math.min(rawDataLength - 1, page));
|
|
87
|
+
}, [handlerOffset, loop, rawDataLength, size]);
|
|
88
|
+
|
|
89
|
+
function setLiveRawIndex(nextIndex: number) {
|
|
90
|
+
liveRawIndex.current = nextIndex;
|
|
97
91
|
}
|
|
98
92
|
|
|
99
93
|
useAnimatedReaction(
|
|
100
94
|
() => {
|
|
101
|
-
if (size <= 0) {
|
|
102
|
-
return {
|
|
103
|
-
i: 0,
|
|
104
|
-
newSharedIndexValue: 0,
|
|
105
|
-
};
|
|
95
|
+
if (size <= 0 || dataLength <= 0 || rawDataLength <= 0) {
|
|
96
|
+
return { physicalIndex: 0, rawIndex: 0 };
|
|
106
97
|
}
|
|
107
98
|
|
|
108
|
-
const
|
|
109
|
-
const toInt = round(handlerOffsetValue / size) % dataInfo.length;
|
|
110
|
-
const isPositive = handlerOffsetValue <= 0;
|
|
111
|
-
const i = isPositive ? Math.abs(toInt) : Math.abs(toInt > 0 ? dataInfo.length - toInt : 0);
|
|
112
|
-
|
|
113
|
-
const newSharedIndexValue = convertToSharedIndex({
|
|
114
|
-
loop,
|
|
115
|
-
rawDataLength: dataInfo.originalLength,
|
|
116
|
-
autoFillData: autoFillData!,
|
|
117
|
-
index: i,
|
|
118
|
-
});
|
|
119
|
-
|
|
99
|
+
const page = getNearestLogicalPage(handlerOffset.value, size);
|
|
120
100
|
return {
|
|
121
|
-
|
|
122
|
-
|
|
101
|
+
physicalIndex: positiveModulo(page, dataLength),
|
|
102
|
+
rawIndex: positiveModulo(page, rawDataLength),
|
|
123
103
|
};
|
|
124
104
|
},
|
|
125
|
-
({
|
|
126
|
-
index.value =
|
|
127
|
-
scheduleOnRN(
|
|
105
|
+
({ physicalIndex, rawIndex }) => {
|
|
106
|
+
index.value = physicalIndex;
|
|
107
|
+
scheduleOnRN(setLiveRawIndex, rawIndex);
|
|
128
108
|
},
|
|
129
|
-
[
|
|
109
|
+
[dataLength, handlerOffset, index, rawDataLength, size]
|
|
130
110
|
);
|
|
131
111
|
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
112
|
+
const settle = React.useCallback(
|
|
113
|
+
(targetIndex?: number) => {
|
|
114
|
+
settleMovement();
|
|
115
|
+
|
|
116
|
+
const nextSettledIndex =
|
|
117
|
+
typeof targetIndex === "number" && rawDataLength > 0
|
|
118
|
+
? positiveModulo(Math.round(targetIndex), rawDataLength)
|
|
119
|
+
: getSettledRawIndex(
|
|
120
|
+
loop
|
|
121
|
+
? getLogicalProgress(handlerOffset.value, size)
|
|
122
|
+
: Math.max(
|
|
123
|
+
0,
|
|
124
|
+
Math.min(rawDataLength - 1, getLogicalProgress(handlerOffset.value, size))
|
|
125
|
+
),
|
|
126
|
+
rawDataLength
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
settledIndex.current = nextSettledIndex;
|
|
130
|
+
return nextSettledIndex;
|
|
131
|
+
},
|
|
132
|
+
[handlerOffset, loop, rawDataLength, settleMovement, size]
|
|
133
|
+
);
|
|
139
134
|
|
|
140
|
-
|
|
141
|
-
|
|
135
|
+
const getCurrentIndex = React.useCallback(() => settledIndex.current, []);
|
|
136
|
+
const getSharedIndex = React.useCallback(() => liveRawIndex.current, []);
|
|
137
|
+
const startMovement = React.useCallback(() => startCommonMovement(), [startCommonMovement]);
|
|
138
|
+
const cancelMovement = React.useCallback(() => cancelCommonMovement(), [cancelCommonMovement]);
|
|
142
139
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
140
|
+
React.useEffect(() => {
|
|
141
|
+
if (!isMoving.value) settle();
|
|
142
|
+
}, [dataRevision, isMoving, rawDataLength, settle]);
|
|
146
143
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
options.onScrollEnd?.();
|
|
152
|
-
}, [options]);
|
|
144
|
+
const isReady = React.useCallback(() => {
|
|
145
|
+
const currentSize = resolvedSize.value ?? size;
|
|
146
|
+
return sizePhase.value === "ready" && currentSize > 0;
|
|
147
|
+
}, [resolvedSize, size, sizePhase]);
|
|
153
148
|
|
|
154
|
-
const
|
|
149
|
+
const emitStart = React.useCallback(() => {
|
|
150
|
+
startMovement();
|
|
155
151
|
options.onScrollStart?.();
|
|
156
|
-
}, [options]);
|
|
152
|
+
}, [options, startMovement]);
|
|
157
153
|
|
|
158
|
-
const
|
|
159
|
-
(
|
|
154
|
+
const emitSettle = React.useCallback(
|
|
155
|
+
(targetIndex?: number) => {
|
|
156
|
+
const nextSettledIndex = settle(targetIndex);
|
|
157
|
+
options.onMovementEnd?.(nextSettledIndex);
|
|
158
|
+
},
|
|
159
|
+
[options, settle]
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
const animateTo = React.useCallback(
|
|
163
|
+
(targetOffset: number, targetIndex: number, onFinished?: () => void) => {
|
|
160
164
|
"worklet";
|
|
161
|
-
|
|
165
|
+
return dealWithAnimation(animation)(targetOffset, (finished) => {
|
|
162
166
|
"worklet";
|
|
163
|
-
if (
|
|
164
|
-
scheduleOnRN(
|
|
165
|
-
onFinished
|
|
167
|
+
if (finished) {
|
|
168
|
+
scheduleOnRN(emitSettle, targetIndex);
|
|
169
|
+
if (onFinished) scheduleOnRN(onFinished);
|
|
170
|
+
} else {
|
|
171
|
+
scheduleOnRN(cancelMovement);
|
|
166
172
|
}
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
const defaultWithAnimation: WithTimingAnimation = {
|
|
170
|
-
type: "timing",
|
|
171
|
-
config: { duration, easing: Easing.easeOutQuart },
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
return dealWithAnimation(withAnimation ?? defaultWithAnimation)(toValue, callback);
|
|
173
|
+
});
|
|
175
174
|
},
|
|
176
|
-
[
|
|
175
|
+
[animation, cancelMovement, emitSettle]
|
|
177
176
|
);
|
|
178
177
|
|
|
179
|
-
const
|
|
180
|
-
|
|
181
|
-
const next = React.useCallback(
|
|
182
|
-
(opts: TCarouselActionOptions = {}) => {
|
|
178
|
+
const moveToPage = React.useCallback(
|
|
179
|
+
(targetPage: number, animated: boolean, onFinished?: () => void) => {
|
|
183
180
|
"worklet";
|
|
184
|
-
const
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
if (!loop) {
|
|
188
|
-
const newIndex = index.value + count;
|
|
189
|
-
const isOutOfBounds = newIndex > dataInfo.length - 1;
|
|
190
|
-
if (isOutOfBounds) {
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
/*
|
|
196
|
-
[Overscroll Protection Logic]
|
|
197
|
-
|
|
198
|
-
This section handles the overscroll protection when overscrollEnabled is false.
|
|
199
|
-
It prevents scrolling beyond the visible content area.
|
|
200
|
-
|
|
201
|
-
Example scenario:
|
|
202
|
-
- Container width: 300px
|
|
203
|
-
- Item width: 75px (4 items per view)
|
|
204
|
-
- Total items: 6
|
|
205
|
-
|
|
206
|
-
Initial state (index = 0):
|
|
207
|
-
[0][1][2][3] | [4][5]
|
|
208
|
-
visible | remaining
|
|
209
|
-
|
|
210
|
-
After 2 slides (index = 2):
|
|
211
|
-
[0][1] | [2][3][4][5]
|
|
212
|
-
hidden | visible
|
|
213
|
-
|
|
214
|
-
The visibleContentWidth calculation:
|
|
215
|
-
- At index 2, remaining items = 4 (items 2,3,4,5)
|
|
216
|
-
- visibleContentWidth = 4 * 75px = 300px
|
|
217
|
-
|
|
218
|
-
If we try to slide again:
|
|
219
|
-
- New visibleContentWidth would be: 2 * 75px = 150px (only items 4,5 remain)
|
|
220
|
-
- Since 150px < container width (300px), the slide is prevented
|
|
221
|
-
|
|
222
|
-
This ensures we don't scroll beyond the last set of fully visible items,
|
|
223
|
-
maintaining a clean UX without partial item visibility at the edges.
|
|
224
|
-
*/
|
|
225
|
-
// For overscroll calculation, use the intended item size, not the measured container size
|
|
226
|
-
// In the new dynamic size system, the measured `size` could reflect the container rather than
|
|
227
|
-
// each item, so prefer explicit width/height props and fall back to style-based dimensions.
|
|
228
|
-
const styleWidth =
|
|
229
|
-
typeof flattenedStyle.width === "number" ? flattenedStyle.width : undefined;
|
|
230
|
-
const styleHeight =
|
|
231
|
-
typeof flattenedStyle.height === "number" ? flattenedStyle.height : undefined;
|
|
232
|
-
const propWidth = typeof width === "number" ? width : undefined;
|
|
233
|
-
const propHeight = typeof height === "number" ? height : undefined;
|
|
234
|
-
|
|
235
|
-
// Use the page size (derived from itemWidth/itemHeight) for overscroll calculations.
|
|
236
|
-
// Fallback to container/style dimensions only if page size is unavailable.
|
|
237
|
-
const pageSize =
|
|
238
|
-
size > 0
|
|
239
|
-
? size
|
|
240
|
-
: vertical
|
|
241
|
-
? (propHeight ?? styleHeight ?? 0)
|
|
242
|
-
: (propWidth ?? styleWidth ?? 0);
|
|
243
|
-
|
|
244
|
-
const visibleContentWidth = (dataInfo.length - index.value) * pageSize;
|
|
245
|
-
|
|
246
|
-
// Get effective container width, with fallback for cases where containerSize
|
|
247
|
-
// hasn't been updated yet (e.g., in tests or during initialization)
|
|
248
|
-
const getEffectiveContainerWidth = () => {
|
|
249
|
-
// 1. Use measured value if available
|
|
250
|
-
if (containerSize.value.width > 0) {
|
|
251
|
-
return containerSize.value.width;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
// 2. Fallback to style width/height when no measurement available
|
|
255
|
-
if (!vertical) {
|
|
256
|
-
if (propWidth && propWidth > 0) {
|
|
257
|
-
return propWidth;
|
|
258
|
-
}
|
|
259
|
-
if (styleWidth && styleWidth > 0) {
|
|
260
|
-
return styleWidth;
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
if (vertical) {
|
|
264
|
-
if (propHeight && propHeight > 0) {
|
|
265
|
-
return propHeight;
|
|
266
|
-
}
|
|
267
|
-
if (styleHeight && styleHeight > 0) {
|
|
268
|
-
return styleHeight;
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
// 3. Final fallback - assume multiple items are visible
|
|
273
|
-
return pageSize * 3; // Assume 3 items per view as reasonable default
|
|
274
|
-
};
|
|
275
|
-
|
|
276
|
-
const effectiveContainerWidth = getEffectiveContainerWidth();
|
|
277
|
-
|
|
278
|
-
if (!overscrollEnabled && effectiveContainerWidth > 0) {
|
|
279
|
-
if (!(visibleContentWidth > effectiveContainerWidth)) {
|
|
280
|
-
return;
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
onScrollStart?.();
|
|
285
|
-
|
|
286
|
-
const nextPage = currentFixedPage() + count;
|
|
287
|
-
index.value = nextPage;
|
|
181
|
+
const targetRawIndex = positiveModulo(targetPage, rawDataLength);
|
|
182
|
+
emitStart();
|
|
183
|
+
index.value = positiveModulo(targetPage, Math.max(dataLength, 1));
|
|
288
184
|
|
|
185
|
+
const targetOffset = -targetPage * size;
|
|
289
186
|
if (animated) {
|
|
290
|
-
handlerOffset.value =
|
|
187
|
+
handlerOffset.value = animateTo(targetOffset, targetRawIndex, onFinished);
|
|
291
188
|
} else {
|
|
292
|
-
handlerOffset.value =
|
|
189
|
+
handlerOffset.value = targetOffset;
|
|
190
|
+
emitSettle(targetRawIndex);
|
|
293
191
|
onFinished?.();
|
|
294
192
|
}
|
|
295
193
|
},
|
|
296
|
-
[
|
|
297
|
-
canSliding,
|
|
298
|
-
loop,
|
|
299
|
-
index,
|
|
300
|
-
dataInfo,
|
|
301
|
-
onScrollStart,
|
|
302
|
-
handlerOffset,
|
|
303
|
-
size,
|
|
304
|
-
scrollWithTiming,
|
|
305
|
-
currentFixedPage,
|
|
306
|
-
overscrollEnabled,
|
|
307
|
-
containerSize,
|
|
308
|
-
vertical,
|
|
309
|
-
flattenedStyle,
|
|
310
|
-
width,
|
|
311
|
-
height,
|
|
312
|
-
]
|
|
194
|
+
[animateTo, dataLength, emitSettle, emitStart, handlerOffset, index, rawDataLength, size]
|
|
313
195
|
);
|
|
314
196
|
|
|
315
|
-
const
|
|
316
|
-
(
|
|
317
|
-
|
|
318
|
-
if (
|
|
319
|
-
|
|
320
|
-
if (!loop && index.value <= 0) return;
|
|
197
|
+
const validateCount = React.useCallback(
|
|
198
|
+
(command: "next" | "prev", count: number) => {
|
|
199
|
+
if (count === 0) return false;
|
|
200
|
+
if (Number.isInteger(count) && count > 0) return true;
|
|
321
201
|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
if (animated) {
|
|
328
|
-
handlerOffset.value = scrollWithTiming(-prevPage * size, onFinished);
|
|
329
|
-
} else {
|
|
330
|
-
handlerOffset.value = -prevPage * size;
|
|
331
|
-
onFinished?.();
|
|
332
|
-
}
|
|
202
|
+
warnOnce(
|
|
203
|
+
`${command}:count`,
|
|
204
|
+
`${command} count must be a positive integer; received ${String(count)}.`
|
|
205
|
+
);
|
|
206
|
+
return false;
|
|
333
207
|
},
|
|
334
|
-
[
|
|
335
|
-
canSliding,
|
|
336
|
-
loop,
|
|
337
|
-
index,
|
|
338
|
-
onScrollStart,
|
|
339
|
-
handlerOffset,
|
|
340
|
-
size,
|
|
341
|
-
scrollWithTiming,
|
|
342
|
-
currentFixedPage,
|
|
343
|
-
]
|
|
208
|
+
[warnOnce]
|
|
344
209
|
);
|
|
345
210
|
|
|
346
|
-
const
|
|
347
|
-
(
|
|
348
|
-
|
|
211
|
+
const next = React.useCallback(
|
|
212
|
+
(stepOptions: InternalCarouselStepOptions = {}) => {
|
|
213
|
+
"worklet";
|
|
214
|
+
const { animated = true, count = 1, onFinished } = stepOptions;
|
|
215
|
+
if (!canMove || !isReady() || !validateCount("next", count)) return;
|
|
349
216
|
|
|
350
|
-
|
|
217
|
+
const currentPage = currentVisualPage();
|
|
218
|
+
const targetPage = loop
|
|
219
|
+
? currentPage + count
|
|
220
|
+
: Math.min(rawDataLength - 1, currentPage + count);
|
|
221
|
+
if (targetPage === currentPage) return;
|
|
351
222
|
|
|
352
|
-
|
|
223
|
+
moveToPage(targetPage, animated, onFinished);
|
|
224
|
+
},
|
|
225
|
+
[canMove, currentVisualPage, isReady, loop, moveToPage, rawDataLength, validateCount]
|
|
226
|
+
);
|
|
353
227
|
|
|
354
|
-
|
|
355
|
-
|
|
228
|
+
const prev = React.useCallback(
|
|
229
|
+
(stepOptions: InternalCarouselStepOptions = {}) => {
|
|
230
|
+
"worklet";
|
|
231
|
+
const { animated = true, count = 1, onFinished } = stepOptions;
|
|
232
|
+
if (!canMove || !isReady() || !validateCount("prev", count)) return;
|
|
356
233
|
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
finalOffset = -i * size;
|
|
361
|
-
} else {
|
|
362
|
-
// direction -> 1 | -1
|
|
363
|
-
let direction: -1 | 1;
|
|
364
|
-
if (fixedDirection === "positive") direction = 1;
|
|
365
|
-
else if (fixedDirection === "negative") direction = -1;
|
|
366
|
-
else direction = handlerOffsetDirection(handlerOffset);
|
|
367
|
-
|
|
368
|
-
// target offset
|
|
369
|
-
const offset = i * size * direction;
|
|
370
|
-
// page width size * page count
|
|
371
|
-
const totalSize = dataInfo.length * size;
|
|
372
|
-
const isCloseToNextLoop = Math.abs(handlerOffset.value % totalSize) / totalSize >= 0.5;
|
|
373
|
-
|
|
374
|
-
finalOffset =
|
|
375
|
-
(Math.floor(Math.abs(handlerOffset.value / totalSize)) + (isCloseToNextLoop ? 1 : 0)) *
|
|
376
|
-
totalSize *
|
|
377
|
-
direction +
|
|
378
|
-
offset;
|
|
379
|
-
}
|
|
234
|
+
const currentPage = currentVisualPage();
|
|
235
|
+
const targetPage = loop ? currentPage - count : Math.max(0, currentPage - count);
|
|
236
|
+
if (targetPage === currentPage) return;
|
|
380
237
|
|
|
381
|
-
|
|
382
|
-
index.value = i;
|
|
383
|
-
handlerOffset.value = scrollWithTiming(finalOffset, onFinished);
|
|
384
|
-
} else {
|
|
385
|
-
handlerOffset.value = finalOffset;
|
|
386
|
-
index.value = i;
|
|
387
|
-
onFinished?.();
|
|
388
|
-
}
|
|
238
|
+
moveToPage(targetPage, animated, onFinished);
|
|
389
239
|
},
|
|
390
|
-
[
|
|
391
|
-
size,
|
|
392
|
-
loop,
|
|
393
|
-
index,
|
|
394
|
-
fixedDirection,
|
|
395
|
-
handlerOffset,
|
|
396
|
-
dataInfo.length,
|
|
397
|
-
canSliding,
|
|
398
|
-
onScrollStart,
|
|
399
|
-
scrollWithTiming,
|
|
400
|
-
]
|
|
240
|
+
[canMove, currentVisualPage, isReady, loop, moveToPage, validateCount]
|
|
401
241
|
);
|
|
402
242
|
|
|
403
243
|
const scrollTo = React.useCallback(
|
|
404
|
-
(
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
if (
|
|
408
|
-
|
|
244
|
+
(scrollOptions: InternalCarouselScrollToOptions) => {
|
|
245
|
+
"worklet";
|
|
246
|
+
const { animated = true, index: targetIndex, onFinished } = scrollOptions;
|
|
247
|
+
if (!canMove || !isReady()) return;
|
|
248
|
+
|
|
249
|
+
if (!Number.isInteger(targetIndex) || targetIndex < 0 || targetIndex >= rawDataLength) {
|
|
250
|
+
warnOnce(
|
|
251
|
+
"scrollTo:index",
|
|
252
|
+
`scrollTo index must be an integer between 0 and ${rawDataLength - 1}; received ${String(targetIndex)}.`
|
|
253
|
+
);
|
|
409
254
|
return;
|
|
410
255
|
}
|
|
411
256
|
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
257
|
+
const currentPage = currentVisualPage();
|
|
258
|
+
const currentRawIndex = positiveModulo(currentPage, rawDataLength);
|
|
259
|
+
if (currentRawIndex === targetIndex) return;
|
|
260
|
+
|
|
261
|
+
const targetPage = loop
|
|
262
|
+
? getShortestLoopTargetPage({
|
|
263
|
+
currentPage,
|
|
264
|
+
targetIndex,
|
|
265
|
+
count: rawDataLength,
|
|
266
|
+
})
|
|
267
|
+
: targetIndex;
|
|
268
|
+
moveToPage(targetPage, animated, onFinished);
|
|
418
269
|
},
|
|
419
|
-
[
|
|
270
|
+
[canMove, currentVisualPage, isReady, loop, moveToPage, rawDataLength, warnOnce]
|
|
420
271
|
);
|
|
421
272
|
|
|
422
273
|
React.useImperativeHandle(
|
|
@@ -435,7 +286,10 @@ export function useCarouselController(options: IOpts): ICarouselController {
|
|
|
435
286
|
prev,
|
|
436
287
|
scrollTo,
|
|
437
288
|
getCurrentIndex,
|
|
438
|
-
getSharedIndex
|
|
289
|
+
getSharedIndex,
|
|
439
290
|
index,
|
|
291
|
+
startMovement,
|
|
292
|
+
cancelMovement,
|
|
293
|
+
settle,
|
|
440
294
|
};
|
|
441
295
|
}
|