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
|
@@ -2,57 +2,32 @@ import type { SharedValue } from "react-native-reanimated";
|
|
|
2
2
|
import { useAnimatedReaction } from "react-native-reanimated";
|
|
3
3
|
import { scheduleOnRN } from "react-native-worklets";
|
|
4
4
|
|
|
5
|
-
import type {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
export function useOnProgressChange(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const { autoFillData, loop, offsetX, size, rawDataLength, onProgressChange, sizeReady } = opts;
|
|
19
|
-
|
|
20
|
-
// remember `isFunc` here because we can't accurately check typeof
|
|
21
|
-
// from within useAnimatedReaction because its code has been workletized;
|
|
22
|
-
// the `onProgressChange` value will be typeof "object" from within
|
|
23
|
-
// the worklet code even if it's a function.
|
|
24
|
-
const isFunc = typeof onProgressChange === "function";
|
|
5
|
+
import type { CarouselProgressChangeHandler } from "../types";
|
|
6
|
+
import { getLogicalProgress } from "../utils/carousel-math";
|
|
7
|
+
|
|
8
|
+
export function useOnProgressChange(options: {
|
|
9
|
+
loop: boolean;
|
|
10
|
+
offset: SharedValue<number>;
|
|
11
|
+
onProgressChange?: CarouselProgressChangeHandler;
|
|
12
|
+
progress?: SharedValue<number>;
|
|
13
|
+
rawDataLength: number;
|
|
14
|
+
size: number;
|
|
15
|
+
sizeReady: SharedValue<boolean>;
|
|
16
|
+
}) {
|
|
17
|
+
const { loop, offset, onProgressChange, progress, rawDataLength, size, sizeReady } = options;
|
|
25
18
|
|
|
26
19
|
useAnimatedReaction(
|
|
27
|
-
() =>
|
|
28
|
-
|
|
29
|
-
const safeSize = size > 0 ? size : 0;
|
|
30
|
-
if (!ready || safeSize <= 0) return;
|
|
31
|
-
|
|
32
|
-
let value = computedOffsetXValueWithAutoFillData({
|
|
33
|
-
value: offset,
|
|
34
|
-
rawDataLength,
|
|
35
|
-
size: safeSize,
|
|
36
|
-
autoFillData,
|
|
37
|
-
loop,
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
if (!loop) {
|
|
41
|
-
value = Math.max(-((rawDataLength - 1) * safeSize), Math.min(value, 0));
|
|
42
|
-
}
|
|
20
|
+
() => {
|
|
21
|
+
if (!sizeReady.value || size <= 0 || rawDataLength <= 0) return null;
|
|
43
22
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
if (
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
} else {
|
|
52
|
-
(onProgressChange as SharedValue<number>).value = absoluteProgress;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
23
|
+
const logicalProgress = getLogicalProgress(offset.value, size);
|
|
24
|
+
return loop ? logicalProgress : Math.max(0, Math.min(rawDataLength - 1, logicalProgress));
|
|
25
|
+
},
|
|
26
|
+
(nextProgress) => {
|
|
27
|
+
if (nextProgress == null) return;
|
|
28
|
+
if (progress) progress.value = nextProgress;
|
|
29
|
+
if (onProgressChange) scheduleOnRN(onProgressChange, nextProgress);
|
|
55
30
|
},
|
|
56
|
-
[loop,
|
|
31
|
+
[loop, offset, onProgressChange, progress, rawDataLength, size, sizeReady]
|
|
57
32
|
);
|
|
58
33
|
}
|
|
@@ -2,16 +2,16 @@ import { useMemo } from "react";
|
|
|
2
2
|
import type {
|
|
3
3
|
GestureStateChangeEvent,
|
|
4
4
|
GestureUpdateEvent,
|
|
5
|
-
PanGesture,
|
|
6
5
|
PanGestureHandlerEventPayload,
|
|
7
6
|
} from "react-native-gesture-handler";
|
|
8
7
|
import { Gesture } from "react-native-gesture-handler";
|
|
9
8
|
|
|
9
|
+
import type { CarouselPanGesture } from "../types";
|
|
10
10
|
import type { GestureConfig } from "./useUpdateGestureConfig";
|
|
11
11
|
import { useUpdateGestureConfig } from "./useUpdateGestureConfig";
|
|
12
12
|
|
|
13
13
|
export const usePanGestureProxy = (customization: {
|
|
14
|
-
onConfigurePanGesture?: (gesture:
|
|
14
|
+
onConfigurePanGesture?: (gesture: CarouselPanGesture) => void;
|
|
15
15
|
onGestureStart: (event: GestureStateChangeEvent<PanGestureHandlerEventPayload>) => void;
|
|
16
16
|
onGestureUpdate: (event: GestureUpdateEvent<PanGestureHandlerEventPayload>) => void;
|
|
17
17
|
onGestureEnd: (
|
|
@@ -1,99 +1,41 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { StyleSheet } from "react-native";
|
|
2
|
+
import { type StyleProp, StyleSheet, type ViewStyle } from "react-native";
|
|
3
3
|
|
|
4
|
-
import type {
|
|
4
|
+
import type { InitializedCarouselProps } from "./useInitProps";
|
|
5
5
|
|
|
6
|
-
export function usePropsErrorBoundary(props:
|
|
7
|
-
React.
|
|
8
|
-
|
|
6
|
+
export function usePropsErrorBoundary(props: InitializedCarouselProps<unknown>) {
|
|
7
|
+
const warned = React.useRef({
|
|
8
|
+
contentStyle: false,
|
|
9
|
+
missingMainAxisSize: false,
|
|
10
|
+
});
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
React.useEffect(() => {
|
|
13
|
+
if (!__DEV__) return;
|
|
14
|
+
|
|
15
|
+
const { contentContainerStyle, orientation, style } = props;
|
|
16
|
+
const flattenedContentStyle =
|
|
17
|
+
StyleSheet.flatten(contentContainerStyle as StyleProp<ViewStyle>) || {};
|
|
18
|
+
if (
|
|
19
|
+
(flattenedContentStyle.opacity !== undefined ||
|
|
20
|
+
flattenedContentStyle.transform !== undefined) &&
|
|
21
|
+
!warned.current.contentStyle
|
|
22
|
+
) {
|
|
23
|
+
console.warn(
|
|
24
|
+
"[react-native-reanimated-carousel] `contentContainerStyle` cannot set `opacity` or `transform`; those fields are owned by Carousel and were ignored."
|
|
25
|
+
);
|
|
26
|
+
warned.current.contentStyle = true;
|
|
14
27
|
}
|
|
15
28
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
warnedRefs.width = true;
|
|
27
|
-
}
|
|
28
|
-
if (typeof height === "number" && !warnedRefs.height) {
|
|
29
|
-
console.warn(
|
|
30
|
-
"[react-native-reanimated-carousel] The `height` prop is deprecated. Please use `style={{ height: ... }}` instead."
|
|
31
|
-
);
|
|
32
|
-
warnedRefs.height = true;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// Conflict warning for contentContainerStyle
|
|
36
|
-
const { opacity, transform } = StyleSheet.flatten(contentContainerStyle) || {};
|
|
37
|
-
if ((opacity !== undefined || transform !== undefined) && !warnedRefs.conflict) {
|
|
38
|
-
console.warn(
|
|
39
|
-
"[react-native-reanimated-carousel] Do not set 'opacity' or 'transform' on 'contentContainerStyle' as it may conflict with animations."
|
|
40
|
-
);
|
|
41
|
-
warnedRefs.conflict = true;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// Updated missing size warnings
|
|
45
|
-
const hasFlexibleContainerSize = typeof flex === "number" && flex > 0;
|
|
46
|
-
const hasHorizontalContainerSize =
|
|
47
|
-
styleWidth != null || typeof width === "number" || hasFlexibleContainerSize;
|
|
48
|
-
const hasVerticalContainerSize =
|
|
49
|
-
styleHeight != null || typeof height === "number" || hasFlexibleContainerSize;
|
|
50
|
-
|
|
51
|
-
if (!vertical && !hasHorizontalContainerSize && !warnedRefs.horizontal) {
|
|
52
|
-
console.warn(
|
|
53
|
-
"[react-native-reanimated-carousel] Horizontal mode did not specify `width` in `style`, will fall back to automatic measurement mode."
|
|
54
|
-
);
|
|
55
|
-
warnedRefs.horizontal = true;
|
|
56
|
-
}
|
|
57
|
-
if (vertical && !hasVerticalContainerSize && !warnedRefs.vertical) {
|
|
58
|
-
console.warn(
|
|
59
|
-
"[react-native-reanimated-carousel] Vertical mode did not specify `height` in `style`, will fall back to automatic measurement mode."
|
|
60
|
-
);
|
|
61
|
-
warnedRefs.vertical = true;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// Page-size guidance (common pitfall): setting itemWidth/itemHeight without container size.
|
|
65
|
-
if (
|
|
66
|
-
!vertical &&
|
|
67
|
-
typeof itemWidth === "number" &&
|
|
68
|
-
!hasHorizontalContainerSize &&
|
|
69
|
-
!warnedRefs.itemWidth
|
|
70
|
-
) {
|
|
71
|
-
console.warn(
|
|
72
|
-
"[react-native-reanimated-carousel] `itemWidth` sets the snapping page size, not the container width. Consider setting container width via `style` (e.g. `style={{ width: '100%' }}` or `flex: 1`)."
|
|
73
|
-
);
|
|
74
|
-
warnedRefs.itemWidth = true;
|
|
75
|
-
}
|
|
76
|
-
if (
|
|
77
|
-
vertical &&
|
|
78
|
-
typeof itemHeight === "number" &&
|
|
79
|
-
!hasVerticalContainerSize &&
|
|
80
|
-
!warnedRefs.itemHeight
|
|
81
|
-
) {
|
|
82
|
-
console.warn(
|
|
83
|
-
"[react-native-reanimated-carousel] `itemHeight` sets the snapping page size, not the container height. Consider setting container height via `style` (e.g. `style={{ height: '100%' }}` or `flex: 1`)."
|
|
84
|
-
);
|
|
85
|
-
warnedRefs.itemHeight = true;
|
|
86
|
-
}
|
|
29
|
+
const flattenedStyle = StyleSheet.flatten(style) || {};
|
|
30
|
+
const mainAxisSize = orientation === "vertical" ? flattenedStyle.height : flattenedStyle.width;
|
|
31
|
+
const hasFlexibleSize =
|
|
32
|
+
(typeof flattenedStyle.flex === "number" && flattenedStyle.flex > 0) ||
|
|
33
|
+
mainAxisSize !== undefined;
|
|
34
|
+
if (!hasFlexibleSize && !warned.current.missingMainAxisSize) {
|
|
35
|
+
console.warn(
|
|
36
|
+
`[react-native-reanimated-carousel] ${orientation} Carousel has no main-axis size in \`style\`; automatic layout measurement will be used.`
|
|
37
|
+
);
|
|
38
|
+
warned.current.missingMainAxisSize = true;
|
|
87
39
|
}
|
|
88
40
|
}, [props]);
|
|
89
41
|
}
|
|
90
|
-
|
|
91
|
-
const warnedRefs: { [key: string]: boolean } = {
|
|
92
|
-
horizontal: false,
|
|
93
|
-
vertical: false,
|
|
94
|
-
width: false,
|
|
95
|
-
height: false,
|
|
96
|
-
conflict: false,
|
|
97
|
-
itemWidth: false,
|
|
98
|
-
itemHeight: false,
|
|
99
|
-
};
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { useEffect } from "react";
|
|
2
|
-
import type { PanGesture } from "react-native-gesture-handler";
|
|
3
2
|
|
|
4
3
|
export interface GestureConfig {
|
|
5
4
|
enabled?: boolean;
|
|
6
5
|
}
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
type ConfigurablePanGesture = {
|
|
8
|
+
enabled(enabled: boolean): unknown;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const useUpdateGestureConfig = (gesture: ConfigurablePanGesture, config: GestureConfig) => {
|
|
9
12
|
const { enabled } = config;
|
|
10
13
|
|
|
11
14
|
useEffect(() => {
|
|
@@ -9,7 +9,7 @@ export interface VisibleRanges {
|
|
|
9
9
|
positiveRange: Range;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export type
|
|
12
|
+
export type VisibleRangesValue = SharedValue<VisibleRanges>;
|
|
13
13
|
|
|
14
14
|
function normalizeWindowSize(total: number, windowSize?: number) {
|
|
15
15
|
"worklet";
|
|
@@ -94,7 +94,7 @@ export function useVisibleRanges(options: {
|
|
|
94
94
|
windowSize?: number;
|
|
95
95
|
translation: SharedValue<number>;
|
|
96
96
|
loop?: boolean;
|
|
97
|
-
}):
|
|
97
|
+
}): VisibleRangesValue {
|
|
98
98
|
const { total = 0, viewSize, translation, windowSize: _windowSize, loop } = options;
|
|
99
99
|
|
|
100
100
|
const windowSize = normalizeWindowSize(total, _windowSize);
|
package/src/index.tsx
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
export { Carousel } from "./components/Carousel";
|
|
2
2
|
export { Pagination } from "./components/Pagination";
|
|
3
3
|
|
|
4
4
|
export type {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
CarouselAnimation,
|
|
6
|
+
CarouselItemAnimation,
|
|
7
|
+
CarouselLayout,
|
|
8
|
+
CarouselPanGesture,
|
|
9
|
+
CarouselProgressChangeHandler,
|
|
10
|
+
CarouselProps,
|
|
11
|
+
CarouselRef,
|
|
8
12
|
CarouselRenderItem,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
CarouselRenderItemInfo,
|
|
14
|
+
CarouselScrollToOptions,
|
|
15
|
+
CarouselStepOptions,
|
|
16
|
+
PaginationDotStyle,
|
|
17
|
+
PaginationProps,
|
|
18
|
+
} from "./public-types";
|
package/src/layouts/index.tsx
CHANGED
|
@@ -2,8 +2,6 @@ import { normalLayout } from "./normal";
|
|
|
2
2
|
import { parallaxLayout } from "./parallax";
|
|
3
3
|
import { horizontalStackLayout, verticalStackLayout } from "./stack";
|
|
4
4
|
|
|
5
|
-
export type TMode = "parallax" | "horizontal-stack" | "vertical-stack";
|
|
6
|
-
|
|
7
5
|
export const Layouts = {
|
|
8
6
|
normal: normalLayout,
|
|
9
7
|
parallax: parallaxLayout,
|
package/src/layouts/normal.ts
CHANGED
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
import { interpolate } from "react-native-reanimated";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import type { CarouselDirectionSign } from "../utils/carousel-direction";
|
|
4
|
+
import { toPhysicalHorizontalValue } from "../utils/carousel-direction";
|
|
5
|
+
|
|
6
|
+
export function normalLayout(opts: {
|
|
7
|
+
size: number;
|
|
8
|
+
isVertical: boolean;
|
|
9
|
+
directionSign: CarouselDirectionSign;
|
|
10
|
+
}) {
|
|
11
|
+
const { size, isVertical, directionSign } = opts;
|
|
5
12
|
|
|
6
13
|
return (value: number) => {
|
|
7
14
|
"worklet";
|
|
8
|
-
const
|
|
15
|
+
const logicalTranslate = interpolate(value, [-1, 0, 1], [-size, 0, size]);
|
|
16
|
+
const translate = isVertical
|
|
17
|
+
? logicalTranslate
|
|
18
|
+
: toPhysicalHorizontalValue(logicalTranslate, directionSign);
|
|
9
19
|
|
|
10
20
|
return {
|
|
11
21
|
transform: [
|
|
12
|
-
|
|
22
|
+
isVertical
|
|
13
23
|
? {
|
|
14
24
|
translateY: translate,
|
|
15
25
|
}
|
package/src/layouts/parallax.ts
CHANGED
|
@@ -1,75 +1,48 @@
|
|
|
1
1
|
import { Extrapolation, interpolate } from "react-native-reanimated";
|
|
2
2
|
|
|
3
|
-
import type {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* control prev/next item offset.
|
|
23
|
-
* @default Math.pow(parallaxScrollingScale, 2)
|
|
24
|
-
*/
|
|
25
|
-
parallaxAdjacentItemScale?: number;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export type TParallaxModeProps = IComputedDirectionTypes<{
|
|
29
|
-
/**
|
|
30
|
-
* Carousel Animated transitions.
|
|
31
|
-
*/
|
|
32
|
-
mode?: "parallax";
|
|
33
|
-
modeConfig?: ILayoutConfig;
|
|
34
|
-
}>;
|
|
35
|
-
|
|
36
|
-
export function parallaxLayout(baseConfig: TBaseConfig, modeConfig: ILayoutConfig = {}) {
|
|
37
|
-
const { size, vertical } = baseConfig;
|
|
38
|
-
const {
|
|
39
|
-
parallaxScrollingOffset = 100,
|
|
40
|
-
parallaxScrollingScale = 0.8,
|
|
41
|
-
parallaxAdjacentItemScale = parallaxScrollingScale ** 2,
|
|
42
|
-
} = modeConfig;
|
|
43
|
-
|
|
44
|
-
return (value: number) => {
|
|
3
|
+
import type { CarouselLayout } from "../types";
|
|
4
|
+
import type { CarouselDirectionSign } from "../utils/carousel-direction";
|
|
5
|
+
import { toPhysicalHorizontalValue } from "../utils/carousel-direction";
|
|
6
|
+
|
|
7
|
+
type ParallaxLayout = Extract<CarouselLayout, { type: "parallax" }>;
|
|
8
|
+
|
|
9
|
+
export function parallaxLayout(
|
|
10
|
+
baseConfig: {
|
|
11
|
+
size: number;
|
|
12
|
+
isVertical: boolean;
|
|
13
|
+
directionSign: CarouselDirectionSign;
|
|
14
|
+
},
|
|
15
|
+
config: ParallaxLayout
|
|
16
|
+
) {
|
|
17
|
+
const { size, isVertical, directionSign } = baseConfig;
|
|
18
|
+
const { offset = 100, scale = 0.8, adjacentScale = scale ** 2 } = config;
|
|
19
|
+
|
|
20
|
+
return (relativeProgress: number) => {
|
|
45
21
|
"worklet";
|
|
46
|
-
const
|
|
47
|
-
|
|
22
|
+
const logicalTranslate = interpolate(
|
|
23
|
+
relativeProgress,
|
|
48
24
|
[-1, 0, 1],
|
|
49
|
-
[-size +
|
|
25
|
+
[-size + offset, 0, size - offset]
|
|
50
26
|
);
|
|
27
|
+
const translate = isVertical
|
|
28
|
+
? logicalTranslate
|
|
29
|
+
: toPhysicalHorizontalValue(logicalTranslate, directionSign);
|
|
51
30
|
|
|
52
|
-
const zIndex = Math.round(
|
|
31
|
+
const zIndex = Math.round(
|
|
32
|
+
interpolate(relativeProgress, [-1, 0, 1], [0, size, 0], Extrapolation.CLAMP)
|
|
33
|
+
);
|
|
53
34
|
|
|
54
|
-
const
|
|
55
|
-
|
|
35
|
+
const animatedScale = interpolate(
|
|
36
|
+
relativeProgress,
|
|
56
37
|
[-1, 0, 1],
|
|
57
|
-
[
|
|
38
|
+
[adjacentScale, scale, adjacentScale],
|
|
58
39
|
Extrapolation.CLAMP
|
|
59
40
|
);
|
|
60
41
|
|
|
61
42
|
return {
|
|
62
43
|
transform: [
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
translateY: translate,
|
|
66
|
-
}
|
|
67
|
-
: {
|
|
68
|
-
translateX: translate,
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
scale,
|
|
72
|
-
},
|
|
44
|
+
isVertical ? { translateY: translate } : { translateX: translate },
|
|
45
|
+
{ scale: animatedScale },
|
|
73
46
|
],
|
|
74
47
|
zIndex,
|
|
75
48
|
};
|
package/src/layouts/stack.ts
CHANGED
|
@@ -1,57 +1,36 @@
|
|
|
1
|
-
import { useMemo } from "react";
|
|
2
1
|
import type { TransformsStyle, ViewStyle } from "react-native";
|
|
3
2
|
import { Dimensions } from "react-native";
|
|
4
3
|
import { Extrapolation, interpolate } from "react-native-reanimated";
|
|
5
4
|
|
|
6
|
-
import type {
|
|
5
|
+
import type { CarouselLayout } from "../types";
|
|
6
|
+
import type { CarouselDirectionSign } from "../utils/carousel-direction";
|
|
7
|
+
import { toPhysicalHorizontalValue } from "../utils/carousel-direction";
|
|
7
8
|
|
|
8
9
|
const screen = Dimensions.get("window");
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
showLength?: number;
|
|
12
|
-
moveSize?: number;
|
|
13
|
-
stackInterval?: number;
|
|
14
|
-
scaleInterval?: number;
|
|
15
|
-
opacityInterval?: number;
|
|
16
|
-
rotateZDeg?: number;
|
|
17
|
-
snapDirection?: "left" | "right";
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export type TStackModeProps = IComputedDirectionTypes<{
|
|
21
|
-
/**
|
|
22
|
-
* Carousel Animated transitions.
|
|
23
|
-
*/
|
|
24
|
-
mode?: "horizontal-stack" | "vertical-stack";
|
|
25
|
-
/**
|
|
26
|
-
* Stack animation style.
|
|
27
|
-
* @default
|
|
28
|
-
* snapDirection: 'right',
|
|
29
|
-
* moveSize: window.width,
|
|
30
|
-
* stackInterval: 30,
|
|
31
|
-
* scaleInterval: 0.08,
|
|
32
|
-
* rotateZDeg: 135,
|
|
33
|
-
* opacityInterval: 0.1,
|
|
34
|
-
*/
|
|
35
|
-
modeConfig?: ILayoutConfig;
|
|
36
|
-
}>;
|
|
11
|
+
type StackLayout = Extract<CarouselLayout, { type: "horizontal-stack" | "vertical-stack" }>;
|
|
37
12
|
|
|
38
|
-
export function horizontalStackLayout(
|
|
13
|
+
export function horizontalStackLayout(
|
|
14
|
+
config: StackLayout,
|
|
15
|
+
directionSign: CarouselDirectionSign = 1
|
|
16
|
+
) {
|
|
39
17
|
return (_value: number) => {
|
|
40
18
|
"worklet";
|
|
41
19
|
|
|
42
20
|
const {
|
|
43
|
-
|
|
44
|
-
snapDirection = "left",
|
|
45
|
-
moveSize = screen.width,
|
|
46
|
-
stackInterval = 18,
|
|
47
|
-
scaleInterval = 0.04,
|
|
48
|
-
opacityInterval = 0.1,
|
|
49
|
-
rotateZDeg = 30,
|
|
50
|
-
} =
|
|
51
|
-
|
|
21
|
+
visibleCount,
|
|
22
|
+
exitDirection: snapDirection = "left",
|
|
23
|
+
exitDistance: moveSize = screen.width,
|
|
24
|
+
spacing: stackInterval = 18,
|
|
25
|
+
scaleStep: scaleInterval = 0.04,
|
|
26
|
+
opacityStep: opacityInterval = 0.1,
|
|
27
|
+
rotation: rotateZDeg = 30,
|
|
28
|
+
} = config;
|
|
29
|
+
|
|
30
|
+
const physicalProgress = toPhysicalHorizontalValue(_value, directionSign);
|
|
52
31
|
const { validLength, value, inputRange } = getCommonVariables({
|
|
53
|
-
showLength:
|
|
54
|
-
value:
|
|
32
|
+
showLength: visibleCount!,
|
|
33
|
+
value: physicalProgress,
|
|
55
34
|
snapDirection,
|
|
56
35
|
});
|
|
57
36
|
const { zIndex, opacity } = getCommonStyles({
|
|
@@ -117,41 +96,22 @@ export function horizontalStackLayout(modeConfig: ILayoutConfig = {}) {
|
|
|
117
96
|
};
|
|
118
97
|
}
|
|
119
98
|
|
|
120
|
-
export function
|
|
121
|
-
customAnimationConfig: ILayoutConfig = {},
|
|
122
|
-
customConfig: CustomConfig = {}
|
|
123
|
-
) {
|
|
124
|
-
const config = useMemo(
|
|
125
|
-
() => ({
|
|
126
|
-
type: customAnimationConfig.snapDirection === "right" ? "negative" : "positive",
|
|
127
|
-
viewCount: customAnimationConfig.showLength,
|
|
128
|
-
...customConfig,
|
|
129
|
-
}),
|
|
130
|
-
[customAnimationConfig, customConfig]
|
|
131
|
-
);
|
|
132
|
-
|
|
133
|
-
return {
|
|
134
|
-
layout: horizontalStackLayout(customAnimationConfig),
|
|
135
|
-
config,
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
export function verticalStackLayout(modeConfig: ILayoutConfig = {}) {
|
|
99
|
+
export function verticalStackLayout(config: StackLayout) {
|
|
140
100
|
return (_value: number) => {
|
|
141
101
|
"worklet";
|
|
142
102
|
|
|
143
103
|
const {
|
|
144
|
-
|
|
145
|
-
snapDirection = "left",
|
|
146
|
-
moveSize = screen.width,
|
|
147
|
-
stackInterval = 18,
|
|
148
|
-
scaleInterval = 0.04,
|
|
149
|
-
opacityInterval = 0.1,
|
|
150
|
-
rotateZDeg = 30,
|
|
151
|
-
} =
|
|
104
|
+
visibleCount,
|
|
105
|
+
exitDirection: snapDirection = "left",
|
|
106
|
+
exitDistance: moveSize = screen.width,
|
|
107
|
+
spacing: stackInterval = 18,
|
|
108
|
+
scaleStep: scaleInterval = 0.04,
|
|
109
|
+
opacityStep: opacityInterval = 0.1,
|
|
110
|
+
rotation: rotateZDeg = 30,
|
|
111
|
+
} = config;
|
|
152
112
|
|
|
153
113
|
const { validLength, value, inputRange } = getCommonVariables({
|
|
154
|
-
showLength:
|
|
114
|
+
showLength: visibleCount!,
|
|
155
115
|
value: _value,
|
|
156
116
|
snapDirection,
|
|
157
117
|
});
|