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,6 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { StyleSheet, type ViewStyle } from "react-native";
|
|
3
|
-
import { GestureHandlerRootView } from "react-native-gesture-handler";
|
|
2
|
+
import { type StyleProp, StyleSheet, View, type ViewStyle } from "react-native";
|
|
4
3
|
import { useAnimatedReaction, useAnimatedStyle, useDerivedValue } from "react-native-reanimated";
|
|
5
4
|
import { scheduleOnRN } from "react-native-worklets";
|
|
6
5
|
import { useAutoPlay } from "../hooks/useAutoPlay";
|
|
@@ -8,42 +7,29 @@ import { useCarouselController } from "../hooks/useCarouselController";
|
|
|
8
7
|
import { useLayoutConfig } from "../hooks/useLayoutConfig";
|
|
9
8
|
import { useOnProgressChange } from "../hooks/useOnProgressChange";
|
|
10
9
|
import { useGlobalState } from "../store";
|
|
11
|
-
import {
|
|
12
|
-
import { computedRealIndexWithAutoFillData } from "../utils/computed-with-auto-fill-data";
|
|
10
|
+
import type { CarouselRef } from "../types";
|
|
13
11
|
import { ItemRenderer } from "./ItemRenderer";
|
|
14
12
|
import { ScrollViewGesture } from "./ScrollViewGesture";
|
|
15
13
|
|
|
16
|
-
export type TAnimationStyle = (value: number) => ViewStyle;
|
|
17
|
-
|
|
18
14
|
export function resolveCarouselLayoutStyle(params: {
|
|
19
15
|
flattenedStyle: Partial<ViewStyle>;
|
|
20
|
-
|
|
16
|
+
isVertical: boolean;
|
|
21
17
|
measuredSize: number;
|
|
22
18
|
sizeExplicit: boolean;
|
|
23
|
-
legacyWidth?: number;
|
|
24
|
-
legacyHeight?: number;
|
|
25
19
|
}) {
|
|
26
20
|
"worklet";
|
|
27
21
|
|
|
28
|
-
const { flattenedStyle,
|
|
29
|
-
params;
|
|
22
|
+
const { flattenedStyle, isVertical, measuredSize, sizeExplicit } = params;
|
|
30
23
|
const { width, height } = flattenedStyle;
|
|
31
|
-
const hasLegacyMainAxisSize = vertical
|
|
32
|
-
? typeof legacyHeight === "number" && legacyHeight > 0
|
|
33
|
-
: typeof legacyWidth === "number" && legacyWidth > 0;
|
|
34
|
-
const shouldUseMeasuredMainAxisSize = sizeExplicit || hasLegacyMainAxisSize;
|
|
35
24
|
const resolvedMainAxisSize = measuredSize || "100%";
|
|
36
25
|
|
|
37
26
|
return {
|
|
38
|
-
width:
|
|
39
|
-
|
|
40
|
-
height:
|
|
41
|
-
height ??
|
|
42
|
-
(vertical ? (shouldUseMeasuredMainAxisSize ? resolvedMainAxisSize : "100%") : "100%"),
|
|
27
|
+
width: width ?? (isVertical ? "100%" : sizeExplicit ? resolvedMainAxisSize : "100%"),
|
|
28
|
+
height: height ?? (isVertical ? (sizeExplicit ? resolvedMainAxisSize : "100%") : "100%"),
|
|
43
29
|
};
|
|
44
30
|
}
|
|
45
31
|
|
|
46
|
-
export const CarouselLayout = React.forwardRef<
|
|
32
|
+
export const CarouselLayout = React.forwardRef<CarouselRef>((_props, ref) => {
|
|
47
33
|
const { props, common } = useGlobalState();
|
|
48
34
|
|
|
49
35
|
const {
|
|
@@ -52,31 +38,30 @@ export const CarouselLayout = React.forwardRef<ICarouselInstance>((_props, ref)
|
|
|
52
38
|
autoFillData,
|
|
53
39
|
// Fill data with autoFillData
|
|
54
40
|
data,
|
|
41
|
+
rawData,
|
|
55
42
|
// Length of fill data
|
|
56
43
|
dataLength,
|
|
57
44
|
// Length of raw data
|
|
58
45
|
rawDataLength,
|
|
59
|
-
|
|
46
|
+
layout,
|
|
60
47
|
style,
|
|
61
48
|
contentContainerStyle,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
withAnimation,
|
|
69
|
-
fixedDirection,
|
|
49
|
+
orientation,
|
|
50
|
+
autoplay,
|
|
51
|
+
renderWindowSize,
|
|
52
|
+
autoplayDirection,
|
|
53
|
+
autoplayInterval,
|
|
54
|
+
animation,
|
|
70
55
|
renderItem,
|
|
71
|
-
onScrollEnd,
|
|
72
56
|
onSnapToItem,
|
|
73
57
|
onScrollStart,
|
|
74
58
|
onProgressChange,
|
|
75
|
-
|
|
59
|
+
progress,
|
|
60
|
+
itemAnimation,
|
|
76
61
|
defaultIndex,
|
|
77
|
-
|
|
78
|
-
height: legacyHeight,
|
|
62
|
+
keyExtractor,
|
|
79
63
|
} = props;
|
|
64
|
+
const isVertical = orientation === "vertical";
|
|
80
65
|
|
|
81
66
|
const { size, handlerOffset, resolvedSize, sizePhase, sizeExplicit } = common;
|
|
82
67
|
const layoutConfig = useLayoutConfig({ ...props, size });
|
|
@@ -101,100 +86,85 @@ export const CarouselLayout = React.forwardRef<ICarouselInstance>((_props, ref)
|
|
|
101
86
|
}, [loop, dataLength, handlerOffset, resolvedSize]);
|
|
102
87
|
|
|
103
88
|
useOnProgressChange({
|
|
104
|
-
autoFillData,
|
|
105
89
|
loop,
|
|
90
|
+
offset: handlerOffset,
|
|
91
|
+
progress,
|
|
106
92
|
size,
|
|
107
93
|
sizeReady: isSizeReady,
|
|
108
|
-
offsetX,
|
|
109
94
|
rawDataLength,
|
|
110
95
|
onProgressChange,
|
|
111
96
|
});
|
|
112
97
|
|
|
98
|
+
const _onScrollEnd = React.useCallback(
|
|
99
|
+
(realIndex: number) => {
|
|
100
|
+
if (onSnapToItem) onSnapToItem(realIndex);
|
|
101
|
+
},
|
|
102
|
+
[onSnapToItem]
|
|
103
|
+
);
|
|
104
|
+
|
|
113
105
|
const carouselController = useCarouselController({
|
|
114
106
|
ref,
|
|
115
107
|
loop,
|
|
116
108
|
size,
|
|
117
109
|
dataLength,
|
|
118
|
-
|
|
110
|
+
rawDataLength,
|
|
119
111
|
handlerOffset,
|
|
120
|
-
|
|
112
|
+
animation,
|
|
121
113
|
defaultIndex,
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
onScrollEnd: () => scheduleOnRN(_onScrollEnd),
|
|
125
|
-
onScrollStart: () => !!onScrollStart && scheduleOnRN(onScrollStart),
|
|
114
|
+
onMovementEnd: _onScrollEnd,
|
|
115
|
+
onScrollStart,
|
|
126
116
|
});
|
|
127
117
|
|
|
128
|
-
const {
|
|
129
|
-
getSharedIndex,
|
|
130
|
-
// index, // Animated index. Could be used for dynamic dimension
|
|
131
|
-
} = carouselController;
|
|
132
|
-
|
|
133
|
-
const _onScrollEnd = React.useCallback(() => {
|
|
134
|
-
const _sharedIndex = Math.round(getSharedIndex());
|
|
135
|
-
|
|
136
|
-
const realIndex = computedRealIndexWithAutoFillData({
|
|
137
|
-
index: _sharedIndex,
|
|
138
|
-
dataLength: rawDataLength,
|
|
139
|
-
loop,
|
|
140
|
-
autoFillData,
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
if (onSnapToItem) onSnapToItem(realIndex);
|
|
144
|
-
|
|
145
|
-
if (onScrollEnd) onScrollEnd(realIndex);
|
|
146
|
-
}, [loop, autoFillData, rawDataLength, getSharedIndex, onSnapToItem, onScrollEnd]);
|
|
147
|
-
|
|
148
118
|
const {
|
|
149
119
|
start: startAutoPlay,
|
|
150
120
|
pause: pauseAutoPlay,
|
|
151
121
|
trigger: triggerAutoPlay,
|
|
152
122
|
} = useAutoPlay({
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
123
|
+
autoplay,
|
|
124
|
+
autoplayDirection,
|
|
125
|
+
autoplayInterval,
|
|
156
126
|
carouselController,
|
|
157
127
|
});
|
|
158
128
|
|
|
159
129
|
useAnimatedReaction(
|
|
160
130
|
() => ({ ready: isSizeReady.value }),
|
|
161
131
|
(state, previous) => {
|
|
162
|
-
if (!
|
|
132
|
+
if (!autoplay) return;
|
|
163
133
|
if (state.ready === previous?.ready) return;
|
|
164
134
|
|
|
165
135
|
if (state.ready) scheduleOnRN(triggerAutoPlay);
|
|
166
136
|
else scheduleOnRN(pauseAutoPlay);
|
|
167
137
|
},
|
|
168
|
-
[
|
|
138
|
+
[autoplay]
|
|
169
139
|
);
|
|
170
140
|
|
|
171
141
|
const scrollViewGestureOnScrollStart = React.useCallback(() => {
|
|
142
|
+
carouselController.startMovement();
|
|
172
143
|
pauseAutoPlay();
|
|
173
144
|
onScrollStart?.();
|
|
174
|
-
}, [onScrollStart, pauseAutoPlay]);
|
|
145
|
+
}, [carouselController, onScrollStart, pauseAutoPlay]);
|
|
175
146
|
|
|
176
147
|
const scrollViewGestureOnScrollEnd = React.useCallback(() => {
|
|
148
|
+
const settledIndex = carouselController.settle();
|
|
177
149
|
startAutoPlay();
|
|
178
|
-
_onScrollEnd();
|
|
179
|
-
}, [_onScrollEnd, startAutoPlay]);
|
|
150
|
+
_onScrollEnd(settledIndex);
|
|
151
|
+
}, [_onScrollEnd, carouselController, startAutoPlay]);
|
|
180
152
|
|
|
181
153
|
const scrollViewGestureOnTouchBegin = React.useCallback(pauseAutoPlay, [pauseAutoPlay]);
|
|
182
154
|
|
|
183
155
|
const scrollViewGestureOnTouchEnd = React.useCallback(startAutoPlay, [startAutoPlay]);
|
|
184
156
|
|
|
185
157
|
const { opacity, transform, ...restContentContainerStyle } =
|
|
186
|
-
StyleSheet.flatten(contentContainerStyle) || {};
|
|
158
|
+
StyleSheet.flatten(contentContainerStyle as StyleProp<ViewStyle>) || {};
|
|
187
159
|
const flattenedStyle = StyleSheet.flatten(style) || {};
|
|
188
160
|
|
|
189
161
|
const layoutStyle = useAnimatedStyle(() => {
|
|
190
162
|
const measuredSize = resolvedSize.value ?? 0;
|
|
191
163
|
const { width, height } = resolveCarouselLayoutStyle({
|
|
192
164
|
flattenedStyle,
|
|
193
|
-
|
|
165
|
+
isVertical,
|
|
194
166
|
measuredSize,
|
|
195
167
|
sizeExplicit,
|
|
196
|
-
legacyWidth,
|
|
197
|
-
legacyHeight,
|
|
198
168
|
});
|
|
199
169
|
|
|
200
170
|
return {
|
|
@@ -202,31 +172,21 @@ export const CarouselLayout = React.forwardRef<ICarouselInstance>((_props, ref)
|
|
|
202
172
|
height,
|
|
203
173
|
opacity: isSizeReady.value ? 1 : 0,
|
|
204
174
|
};
|
|
205
|
-
}, [
|
|
206
|
-
flattenedStyle,
|
|
207
|
-
isSizeReady,
|
|
208
|
-
vertical,
|
|
209
|
-
resolvedSize,
|
|
210
|
-
sizePhase,
|
|
211
|
-
sizeExplicit,
|
|
212
|
-
legacyWidth,
|
|
213
|
-
legacyHeight,
|
|
214
|
-
]);
|
|
175
|
+
}, [flattenedStyle, isSizeReady, isVertical, resolvedSize, sizePhase, sizeExplicit]);
|
|
215
176
|
|
|
216
177
|
return (
|
|
217
|
-
<
|
|
178
|
+
<View testID={testID} style={[styles.layoutContainer, style]} onLayout={props.onLayout}>
|
|
218
179
|
<ScrollViewGesture
|
|
219
180
|
size={size}
|
|
220
|
-
key={
|
|
181
|
+
key={layout?.type}
|
|
221
182
|
translation={handlerOffset}
|
|
222
183
|
style={[
|
|
223
184
|
styles.contentContainer,
|
|
224
185
|
layoutStyle,
|
|
225
186
|
restContentContainerStyle,
|
|
226
|
-
|
|
187
|
+
isVertical ? styles.itemsVertical : styles.itemsHorizontal,
|
|
227
188
|
]}
|
|
228
189
|
testID="carousel-content-container"
|
|
229
|
-
onLayout={props.onLayout}
|
|
230
190
|
onScrollStart={scrollViewGestureOnScrollStart}
|
|
231
191
|
onScrollEnd={scrollViewGestureOnScrollEnd}
|
|
232
192
|
onTouchBegin={scrollViewGestureOnTouchBegin}
|
|
@@ -234,21 +194,23 @@ export const CarouselLayout = React.forwardRef<ICarouselInstance>((_props, ref)
|
|
|
234
194
|
>
|
|
235
195
|
<ItemRenderer
|
|
236
196
|
data={data}
|
|
197
|
+
rawData={rawData}
|
|
237
198
|
dataLength={dataLength}
|
|
238
199
|
rawDataLength={rawDataLength}
|
|
239
200
|
loop={loop}
|
|
240
201
|
size={size}
|
|
241
|
-
|
|
202
|
+
renderWindowSize={renderWindowSize}
|
|
242
203
|
defaultIndex={defaultIndex}
|
|
243
204
|
autoFillData={autoFillData}
|
|
244
205
|
offsetX={offsetX}
|
|
245
206
|
handlerOffset={handlerOffset}
|
|
246
207
|
layoutConfig={layoutConfig}
|
|
247
208
|
renderItem={renderItem}
|
|
248
|
-
|
|
209
|
+
itemAnimation={itemAnimation}
|
|
210
|
+
keyExtractor={keyExtractor}
|
|
249
211
|
/>
|
|
250
212
|
</ScrollViewGesture>
|
|
251
|
-
</
|
|
213
|
+
</View>
|
|
252
214
|
);
|
|
253
215
|
});
|
|
254
216
|
|
|
@@ -3,21 +3,23 @@ import type { LayoutChangeEvent, ViewStyle } from "react-native";
|
|
|
3
3
|
import { StyleSheet } from "react-native";
|
|
4
4
|
import type { SharedValue } from "react-native-reanimated";
|
|
5
5
|
import Animated, {
|
|
6
|
+
useAnimatedReaction,
|
|
6
7
|
useAnimatedStyle,
|
|
7
8
|
useDerivedValue,
|
|
8
9
|
useSharedValue,
|
|
9
10
|
} from "react-native-reanimated";
|
|
10
|
-
import { scheduleOnUI } from "react-native-worklets";
|
|
11
|
+
import { scheduleOnRN, scheduleOnUI } from "react-native-worklets";
|
|
11
12
|
|
|
12
|
-
import type {
|
|
13
|
+
import type { OffsetOptions } from "../hooks/useOffsetX";
|
|
13
14
|
import { useOffsetX } from "../hooks/useOffsetX";
|
|
14
|
-
import type {
|
|
15
|
-
import type { ILayoutConfig } from "../layouts/stack";
|
|
15
|
+
import type { VisibleRangesValue } from "../hooks/useVisibleRanges";
|
|
16
16
|
import { useGlobalState } from "../store";
|
|
17
|
-
import type {
|
|
17
|
+
import type { CarouselItemAnimation } from "../types";
|
|
18
|
+
import { getHorizontalStackOffsetType } from "../utils/carousel-direction";
|
|
19
|
+
import { positiveModulo } from "../utils/carousel-math";
|
|
18
20
|
import { sanitizeAnimationStyle } from "../utils/sanitize-animation-style";
|
|
19
21
|
|
|
20
|
-
export type
|
|
22
|
+
export type ItemAnimationStyle = CarouselItemAnimation;
|
|
21
23
|
|
|
22
24
|
export function resolveItemMainAxisSize(params: {
|
|
23
25
|
explicitSize?: number;
|
|
@@ -35,29 +37,18 @@ export function resolveItemMainAxisSize(params: {
|
|
|
35
37
|
|
|
36
38
|
export const ItemLayout: React.FC<{
|
|
37
39
|
index: number;
|
|
40
|
+
rawIndex: number;
|
|
38
41
|
handlerOffset: SharedValue<number>;
|
|
39
|
-
visibleRanges:
|
|
40
|
-
animationStyle:
|
|
42
|
+
visibleRanges: VisibleRangesValue;
|
|
43
|
+
animationStyle: ItemAnimationStyle;
|
|
41
44
|
children: (ctx: {
|
|
42
|
-
|
|
45
|
+
relativeProgress: SharedValue<number>;
|
|
43
46
|
}) => React.ReactElement;
|
|
44
47
|
}> = (props) => {
|
|
45
|
-
const { handlerOffset, index, children, visibleRanges, animationStyle } = props;
|
|
48
|
+
const { handlerOffset, index, rawIndex, children, visibleRanges, animationStyle } = props;
|
|
46
49
|
|
|
47
50
|
const {
|
|
48
|
-
props: {
|
|
49
|
-
loop,
|
|
50
|
-
dataLength,
|
|
51
|
-
width,
|
|
52
|
-
height,
|
|
53
|
-
vertical,
|
|
54
|
-
customConfig,
|
|
55
|
-
mode,
|
|
56
|
-
modeConfig,
|
|
57
|
-
style,
|
|
58
|
-
itemWidth,
|
|
59
|
-
itemHeight,
|
|
60
|
-
},
|
|
51
|
+
props: { loop, dataLength, directionSign, orientation, layout, style, itemSize },
|
|
61
52
|
common,
|
|
62
53
|
layout: { updateItemDimensions },
|
|
63
54
|
} = useGlobalState();
|
|
@@ -68,24 +59,19 @@ export const ItemLayout: React.FC<{
|
|
|
68
59
|
});
|
|
69
60
|
|
|
70
61
|
const fallbackSize = common.size;
|
|
71
|
-
|
|
62
|
+
const isVertical = orientation === "vertical";
|
|
72
63
|
const { width: styleWidth, height: styleHeight } = StyleSheet.flatten(style) || {};
|
|
73
64
|
const styleWidthNumber = typeof styleWidth === "number" ? styleWidth : undefined;
|
|
74
65
|
const styleHeightNumber = typeof styleHeight === "number" ? styleHeight : undefined;
|
|
75
66
|
|
|
76
|
-
|
|
77
|
-
const explicitItemSize = vertical ? itemHeight : itemWidth;
|
|
78
|
-
const explicitAxisSize = vertical ? (styleHeightNumber ?? height) : (styleWidthNumber ?? width);
|
|
79
|
-
// Use itemWidth/itemHeight if provided, otherwise fall back to container size
|
|
80
|
-
const size = (explicitItemSize ?? explicitAxisSize ?? fallbackSize) || 0;
|
|
67
|
+
const size = (itemSize ?? fallbackSize) || 0;
|
|
81
68
|
const effectivePageSize = size > 0 ? size : undefined;
|
|
82
69
|
|
|
83
70
|
const dimensionsStyle = useAnimatedStyle<ViewStyle>(() => {
|
|
84
|
-
|
|
85
|
-
const
|
|
86
|
-
const heightCandidate = vertical ? (explicitItemSize ?? explicitAxisSize) : height;
|
|
71
|
+
const widthCandidate = isVertical ? styleWidthNumber : itemSize;
|
|
72
|
+
const heightCandidate = isVertical ? itemSize : styleHeightNumber;
|
|
87
73
|
|
|
88
|
-
const computedWidth =
|
|
74
|
+
const computedWidth = isVertical
|
|
89
75
|
? typeof widthCandidate === "number"
|
|
90
76
|
? widthCandidate
|
|
91
77
|
: (measuredSize.value.width ?? "100%")
|
|
@@ -95,7 +81,7 @@ export const ItemLayout: React.FC<{
|
|
|
95
81
|
measuredSize: measuredSize.value.width,
|
|
96
82
|
});
|
|
97
83
|
|
|
98
|
-
const computedHeight =
|
|
84
|
+
const computedHeight = isVertical
|
|
99
85
|
? resolveItemMainAxisSize({
|
|
100
86
|
explicitSize: heightCandidate,
|
|
101
87
|
effectivePageSize,
|
|
@@ -109,40 +95,59 @@ export const ItemLayout: React.FC<{
|
|
|
109
95
|
width: computedWidth,
|
|
110
96
|
height: computedHeight,
|
|
111
97
|
};
|
|
112
|
-
}, [
|
|
98
|
+
}, [effectivePageSize, isVertical, itemSize, styleHeightNumber, styleWidthNumber]);
|
|
113
99
|
|
|
114
|
-
let offsetXConfig:
|
|
100
|
+
let offsetXConfig: OffsetOptions = {
|
|
115
101
|
handlerOffset,
|
|
116
102
|
index,
|
|
117
103
|
size,
|
|
118
104
|
dataLength,
|
|
119
105
|
loop,
|
|
120
|
-
...(typeof customConfig === "function" ? customConfig() : {}),
|
|
121
106
|
};
|
|
122
107
|
|
|
123
|
-
if (
|
|
124
|
-
const { snapDirection, showLength } = modeConfig as ILayoutConfig;
|
|
125
|
-
|
|
108
|
+
if (layout?.type === "horizontal-stack") {
|
|
126
109
|
offsetXConfig = {
|
|
127
110
|
handlerOffset,
|
|
128
111
|
index,
|
|
129
112
|
size,
|
|
130
113
|
dataLength,
|
|
131
114
|
loop,
|
|
132
|
-
type:
|
|
133
|
-
viewCount:
|
|
115
|
+
type: getHorizontalStackOffsetType(layout.exitDirection ?? "left", directionSign),
|
|
116
|
+
viewCount: layout.visibleCount,
|
|
134
117
|
};
|
|
135
118
|
}
|
|
136
119
|
|
|
137
120
|
const x = useOffsetX(offsetXConfig, visibleRanges);
|
|
138
|
-
const
|
|
121
|
+
const isCurrentForAccessibility = React.useCallback(() => {
|
|
122
|
+
"worklet";
|
|
123
|
+
|
|
124
|
+
return (
|
|
125
|
+
size > 0 &&
|
|
126
|
+
dataLength > 0 &&
|
|
127
|
+
positiveModulo(Math.round(-handlerOffset.value / size), dataLength) === index
|
|
128
|
+
);
|
|
129
|
+
}, [dataLength, handlerOffset, index, size]);
|
|
130
|
+
const [isAccessibilityCurrent, setIsAccessibilityCurrent] =
|
|
131
|
+
React.useState(isCurrentForAccessibility);
|
|
132
|
+
|
|
133
|
+
useAnimatedReaction(
|
|
134
|
+
isCurrentForAccessibility,
|
|
135
|
+
(isCurrent, wasCurrent) => {
|
|
136
|
+
if (isCurrent !== wasCurrent) {
|
|
137
|
+
scheduleOnRN(setIsAccessibilityCurrent, isCurrent);
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
[isCurrentForAccessibility]
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
const relativeProgress = useDerivedValue(() => {
|
|
139
144
|
if (!size) return 0;
|
|
140
145
|
return x.value / size;
|
|
141
146
|
}, [x, size]);
|
|
142
147
|
const animatedStyle = useAnimatedStyle<ViewStyle>(() => {
|
|
143
148
|
const safeSize = size || 1;
|
|
144
|
-
return sanitizeAnimationStyle(animationStyle(x.value / safeSize,
|
|
145
|
-
}, [animationStyle,
|
|
149
|
+
return sanitizeAnimationStyle(animationStyle(x.value / safeSize, rawIndex));
|
|
150
|
+
}, [animationStyle, rawIndex, x, size]);
|
|
146
151
|
|
|
147
152
|
// TODO: For dynamic dimension in the future
|
|
148
153
|
// function handleLayout(e: LayoutChangeEvent) {
|
|
@@ -150,7 +155,7 @@ export const ItemLayout: React.FC<{
|
|
|
150
155
|
// updateItemDimensions(index, { width, height });
|
|
151
156
|
// }
|
|
152
157
|
|
|
153
|
-
const child = children({
|
|
158
|
+
const child = children({ relativeProgress });
|
|
154
159
|
|
|
155
160
|
type LayoutableProps = {
|
|
156
161
|
collapsable?: boolean;
|
|
@@ -185,6 +190,10 @@ export const ItemLayout: React.FC<{
|
|
|
185
190
|
|
|
186
191
|
return (
|
|
187
192
|
<Animated.View
|
|
193
|
+
accessibilityElementsHidden={!isAccessibilityCurrent}
|
|
194
|
+
accessible={isAccessibilityCurrent ? undefined : false}
|
|
195
|
+
aria-hidden={!isAccessibilityCurrent}
|
|
196
|
+
importantForAccessibility={isAccessibilityCurrent ? "auto" : "no-hide-descendants"}
|
|
188
197
|
style={[
|
|
189
198
|
{
|
|
190
199
|
position: "absolute",
|
|
@@ -1,39 +1,41 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { FC } from "react";
|
|
3
|
-
import type { ViewStyle } from "react-native";
|
|
4
3
|
import type { SharedValue } from "react-native-reanimated";
|
|
5
4
|
import { useAnimatedReaction } from "react-native-reanimated";
|
|
6
5
|
import { scheduleOnRN } from "react-native-worklets";
|
|
7
6
|
|
|
8
|
-
import type {
|
|
7
|
+
import type { ItemAnimationStyle } from "./ItemLayout";
|
|
9
8
|
import { ItemLayout } from "./ItemLayout";
|
|
10
9
|
|
|
11
10
|
import type { VisibleRanges } from "../hooks/useVisibleRanges";
|
|
12
11
|
import { computeVisibleRanges, useVisibleRanges } from "../hooks/useVisibleRanges";
|
|
13
|
-
import type { CarouselRenderItem } from "../types";
|
|
12
|
+
import type { CarouselItemAnimation, CarouselRenderItem } from "../types";
|
|
14
13
|
import { computedRealIndexWithAutoFillData } from "../utils/computed-with-auto-fill-data";
|
|
15
14
|
|
|
16
15
|
interface Props {
|
|
17
|
-
data:
|
|
16
|
+
data: unknown[];
|
|
17
|
+
rawData: unknown[];
|
|
18
18
|
dataLength: number;
|
|
19
19
|
rawDataLength: number;
|
|
20
20
|
loop: boolean;
|
|
21
21
|
size: number;
|
|
22
|
-
|
|
22
|
+
renderWindowSize?: number;
|
|
23
23
|
defaultIndex: number;
|
|
24
24
|
autoFillData: boolean;
|
|
25
25
|
offsetX: SharedValue<number>;
|
|
26
26
|
handlerOffset: SharedValue<number>;
|
|
27
|
-
layoutConfig:
|
|
28
|
-
renderItem: CarouselRenderItem<
|
|
29
|
-
|
|
27
|
+
layoutConfig: ItemAnimationStyle;
|
|
28
|
+
renderItem: CarouselRenderItem<unknown>;
|
|
29
|
+
itemAnimation?: CarouselItemAnimation;
|
|
30
|
+
keyExtractor?: (item: unknown, index: number) => string;
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
export const ItemRenderer: FC<Props> = (props) => {
|
|
33
34
|
const {
|
|
34
35
|
data,
|
|
36
|
+
rawData,
|
|
35
37
|
size,
|
|
36
|
-
|
|
38
|
+
renderWindowSize,
|
|
37
39
|
defaultIndex,
|
|
38
40
|
handlerOffset,
|
|
39
41
|
offsetX,
|
|
@@ -43,14 +45,15 @@ export const ItemRenderer: FC<Props> = (props) => {
|
|
|
43
45
|
autoFillData,
|
|
44
46
|
layoutConfig,
|
|
45
47
|
renderItem,
|
|
46
|
-
|
|
48
|
+
itemAnimation,
|
|
49
|
+
keyExtractor,
|
|
47
50
|
} = props;
|
|
48
51
|
|
|
49
52
|
const visibleRanges = useVisibleRanges({
|
|
50
53
|
total: dataLength,
|
|
51
54
|
viewSize: size,
|
|
52
55
|
translation: handlerOffset,
|
|
53
|
-
windowSize,
|
|
56
|
+
windowSize: renderWindowSize,
|
|
54
57
|
loop,
|
|
55
58
|
});
|
|
56
59
|
|
|
@@ -59,11 +62,11 @@ export const ItemRenderer: FC<Props> = (props) => {
|
|
|
59
62
|
() =>
|
|
60
63
|
computeVisibleRanges({
|
|
61
64
|
total: dataLength,
|
|
62
|
-
windowSize,
|
|
65
|
+
windowSize: renderWindowSize,
|
|
63
66
|
currentIndex: defaultIndex,
|
|
64
67
|
loop,
|
|
65
68
|
}),
|
|
66
|
-
[dataLength, defaultIndex, loop,
|
|
69
|
+
[dataLength, defaultIndex, loop, renderWindowSize]
|
|
67
70
|
);
|
|
68
71
|
|
|
69
72
|
const [displayedItems, setDisplayedItems] = React.useState<VisibleRanges>(initialRanges);
|
|
@@ -92,19 +95,27 @@ export const ItemRenderer: FC<Props> = (props) => {
|
|
|
92
95
|
|
|
93
96
|
if (!shouldRender) return null;
|
|
94
97
|
|
|
98
|
+
const rawItem = rawData[realIndex] ?? item;
|
|
99
|
+
const key = keyExtractor
|
|
100
|
+
? `${keyExtractor(rawItem, realIndex)}::rnrc-copy-${Math.floor(
|
|
101
|
+
index / Math.max(rawDataLength, 1)
|
|
102
|
+
)}`
|
|
103
|
+
: String(index);
|
|
104
|
+
|
|
95
105
|
return (
|
|
96
106
|
<ItemLayout
|
|
97
|
-
key={
|
|
107
|
+
key={key}
|
|
98
108
|
index={index}
|
|
109
|
+
rawIndex={realIndex}
|
|
99
110
|
handlerOffset={offsetX}
|
|
100
111
|
visibleRanges={visibleRanges}
|
|
101
|
-
animationStyle={
|
|
112
|
+
animationStyle={itemAnimation || layoutConfig}
|
|
102
113
|
>
|
|
103
|
-
{({
|
|
114
|
+
{({ relativeProgress }) =>
|
|
104
115
|
renderItem({
|
|
105
|
-
item,
|
|
116
|
+
item: rawItem,
|
|
106
117
|
index: realIndex,
|
|
107
|
-
|
|
118
|
+
relativeProgress,
|
|
108
119
|
})
|
|
109
120
|
}
|
|
110
121
|
</ItemLayout>
|