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,247 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { View } from "react-native";
|
|
3
|
-
|
|
4
|
-
import { renderHook } from "@testing-library/react-hooks";
|
|
5
|
-
|
|
6
|
-
import { useLayoutConfig } from "./useLayoutConfig";
|
|
7
|
-
|
|
8
|
-
describe("useLayoutConfig", () => {
|
|
9
|
-
const defaultProps = {
|
|
10
|
-
size: 300,
|
|
11
|
-
vertical: false,
|
|
12
|
-
};
|
|
13
|
-
it("should return normal layout by default", () => {
|
|
14
|
-
const { result } = renderHook(() =>
|
|
15
|
-
useLayoutConfig({
|
|
16
|
-
...defaultProps,
|
|
17
|
-
data: [],
|
|
18
|
-
renderItem: () => <View />,
|
|
19
|
-
loop: false,
|
|
20
|
-
autoFillData: false,
|
|
21
|
-
defaultIndex: 0,
|
|
22
|
-
autoPlayInterval: 0,
|
|
23
|
-
scrollAnimationDuration: 0,
|
|
24
|
-
width: 0,
|
|
25
|
-
height: 0,
|
|
26
|
-
rawData: [],
|
|
27
|
-
dataLength: 0,
|
|
28
|
-
rawDataLength: 0,
|
|
29
|
-
})
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
expect(result.current).toBeDefined();
|
|
33
|
-
expect(typeof result.current).toBe("function");
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it("should handle parallax mode", () => {
|
|
37
|
-
const props = {
|
|
38
|
-
...defaultProps,
|
|
39
|
-
mode: "parallax" as const,
|
|
40
|
-
modeConfig: {
|
|
41
|
-
parallaxScrollingScale: 0.9,
|
|
42
|
-
parallaxScrollingOffset: 50,
|
|
43
|
-
parallaxAdjacentItemScale: 0.8,
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const { result } = renderHook(() =>
|
|
48
|
-
useLayoutConfig({
|
|
49
|
-
...props,
|
|
50
|
-
data: [],
|
|
51
|
-
renderItem: () => <View />,
|
|
52
|
-
loop: false,
|
|
53
|
-
autoFillData: false,
|
|
54
|
-
defaultIndex: 0,
|
|
55
|
-
autoPlayInterval: 0,
|
|
56
|
-
scrollAnimationDuration: 0,
|
|
57
|
-
width: 0,
|
|
58
|
-
height: 0,
|
|
59
|
-
rawData: [],
|
|
60
|
-
dataLength: 0,
|
|
61
|
-
rawDataLength: 0,
|
|
62
|
-
})
|
|
63
|
-
);
|
|
64
|
-
const style = result.current(0); // Test with offset 0
|
|
65
|
-
|
|
66
|
-
expect(style.transform).toBeDefined();
|
|
67
|
-
expect(style.transform).toContainEqual({ translateX: 0 });
|
|
68
|
-
expect(style.transform).toContainEqual({ scale: 0.9 });
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it("should handle horizontal-stack mode", () => {
|
|
72
|
-
const props = {
|
|
73
|
-
...defaultProps,
|
|
74
|
-
mode: "horizontal-stack" as const,
|
|
75
|
-
modeConfig: {
|
|
76
|
-
snapDirection: "left" as const,
|
|
77
|
-
showLength: 3,
|
|
78
|
-
},
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
const { result } = renderHook(() =>
|
|
82
|
-
useLayoutConfig({
|
|
83
|
-
...props,
|
|
84
|
-
data: [],
|
|
85
|
-
renderItem: () => <View />,
|
|
86
|
-
loop: false,
|
|
87
|
-
autoFillData: false,
|
|
88
|
-
defaultIndex: 0,
|
|
89
|
-
autoPlayInterval: 0,
|
|
90
|
-
scrollAnimationDuration: 0,
|
|
91
|
-
width: 0,
|
|
92
|
-
height: 0,
|
|
93
|
-
rawData: [],
|
|
94
|
-
dataLength: 0,
|
|
95
|
-
rawDataLength: 0,
|
|
96
|
-
})
|
|
97
|
-
);
|
|
98
|
-
const style = result.current(0); // Test with offset 0
|
|
99
|
-
|
|
100
|
-
expect(style.transform).toBeDefined();
|
|
101
|
-
expect(style.zIndex).toBeDefined();
|
|
102
|
-
expect(style.opacity).toBeDefined();
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it("should handle vertical-stack mode", () => {
|
|
106
|
-
const props = {
|
|
107
|
-
...defaultProps,
|
|
108
|
-
mode: "vertical-stack" as const,
|
|
109
|
-
modeConfig: {
|
|
110
|
-
snapDirection: "left" as const,
|
|
111
|
-
showLength: 3,
|
|
112
|
-
},
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
const { result } = renderHook(() =>
|
|
116
|
-
useLayoutConfig({
|
|
117
|
-
...props,
|
|
118
|
-
data: [],
|
|
119
|
-
renderItem: () => <View />,
|
|
120
|
-
loop: false,
|
|
121
|
-
autoFillData: false,
|
|
122
|
-
defaultIndex: 0,
|
|
123
|
-
autoPlayInterval: 0,
|
|
124
|
-
scrollAnimationDuration: 0,
|
|
125
|
-
width: 0,
|
|
126
|
-
height: 0,
|
|
127
|
-
rawData: [],
|
|
128
|
-
dataLength: 0,
|
|
129
|
-
rawDataLength: 0,
|
|
130
|
-
})
|
|
131
|
-
);
|
|
132
|
-
const style = result.current(0); // Test with offset 0
|
|
133
|
-
|
|
134
|
-
expect(style.transform).toBeDefined();
|
|
135
|
-
expect(style.zIndex).toBeDefined();
|
|
136
|
-
expect(style.opacity).toBeDefined();
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
it("should handle vertical orientation", () => {
|
|
140
|
-
const props = {
|
|
141
|
-
...defaultProps,
|
|
142
|
-
vertical: true,
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
const { result } = renderHook(() =>
|
|
146
|
-
useLayoutConfig({
|
|
147
|
-
...props,
|
|
148
|
-
data: [],
|
|
149
|
-
renderItem: () => <View />,
|
|
150
|
-
loop: false,
|
|
151
|
-
autoFillData: false,
|
|
152
|
-
defaultIndex: 0,
|
|
153
|
-
autoPlayInterval: 0,
|
|
154
|
-
scrollAnimationDuration: 0,
|
|
155
|
-
width: 0,
|
|
156
|
-
height: 0,
|
|
157
|
-
rawData: [],
|
|
158
|
-
dataLength: 0,
|
|
159
|
-
rawDataLength: 0,
|
|
160
|
-
})
|
|
161
|
-
);
|
|
162
|
-
const style = result.current(0); // Test with offset 0
|
|
163
|
-
|
|
164
|
-
expect(style.transform).toBeDefined();
|
|
165
|
-
expect(style.transform).toContainEqual({ translateY: 0 });
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
it("should handle different offsets", () => {
|
|
169
|
-
const { result } = renderHook(() =>
|
|
170
|
-
useLayoutConfig({
|
|
171
|
-
...defaultProps,
|
|
172
|
-
data: [],
|
|
173
|
-
renderItem: () => <View />,
|
|
174
|
-
loop: false,
|
|
175
|
-
autoFillData: false,
|
|
176
|
-
defaultIndex: 0,
|
|
177
|
-
autoPlayInterval: 0,
|
|
178
|
-
scrollAnimationDuration: 0,
|
|
179
|
-
width: 0,
|
|
180
|
-
height: 0,
|
|
181
|
-
rawData: [],
|
|
182
|
-
dataLength: 0,
|
|
183
|
-
rawDataLength: 0,
|
|
184
|
-
})
|
|
185
|
-
);
|
|
186
|
-
|
|
187
|
-
const style1 = result.current(-1); // Previous item
|
|
188
|
-
const style2 = result.current(0); // Current item
|
|
189
|
-
const style3 = result.current(1); // Next item
|
|
190
|
-
|
|
191
|
-
expect(style1.transform).toContainEqual({ translateX: -300 });
|
|
192
|
-
expect(style2.transform).toContainEqual({ translateX: 0 });
|
|
193
|
-
expect(style3.transform).toContainEqual({ translateX: 300 });
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
it("should memoize layout function", () => {
|
|
197
|
-
const { result, rerender } = renderHook(() =>
|
|
198
|
-
useLayoutConfig({
|
|
199
|
-
...defaultProps,
|
|
200
|
-
data: [],
|
|
201
|
-
renderItem: () => <View />,
|
|
202
|
-
loop: false,
|
|
203
|
-
autoFillData: false,
|
|
204
|
-
defaultIndex: 0,
|
|
205
|
-
autoPlayInterval: 0,
|
|
206
|
-
scrollAnimationDuration: 0,
|
|
207
|
-
width: 0,
|
|
208
|
-
height: 0,
|
|
209
|
-
rawData: [],
|
|
210
|
-
dataLength: 0,
|
|
211
|
-
rawDataLength: 0,
|
|
212
|
-
})
|
|
213
|
-
);
|
|
214
|
-
const firstResult = result.current;
|
|
215
|
-
|
|
216
|
-
rerender();
|
|
217
|
-
expect(result.current).toBe(firstResult);
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
it("should update layout when props change", () => {
|
|
221
|
-
const { result, rerender } = renderHook(
|
|
222
|
-
(props) =>
|
|
223
|
-
useLayoutConfig({
|
|
224
|
-
...props,
|
|
225
|
-
data: [],
|
|
226
|
-
renderItem: () => <View />,
|
|
227
|
-
loop: false,
|
|
228
|
-
autoFillData: false,
|
|
229
|
-
defaultIndex: 0,
|
|
230
|
-
autoPlayInterval: 0,
|
|
231
|
-
scrollAnimationDuration: 0,
|
|
232
|
-
width: 0,
|
|
233
|
-
height: 0,
|
|
234
|
-
rawData: [],
|
|
235
|
-
dataLength: 0,
|
|
236
|
-
rawDataLength: 0,
|
|
237
|
-
}),
|
|
238
|
-
{
|
|
239
|
-
initialProps: defaultProps,
|
|
240
|
-
}
|
|
241
|
-
);
|
|
242
|
-
const firstResult = result.current;
|
|
243
|
-
|
|
244
|
-
rerender({ ...defaultProps, size: 400 });
|
|
245
|
-
expect(result.current).not.toBe(firstResult);
|
|
246
|
-
});
|
|
247
|
-
});
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { useSharedValue } from "react-native-reanimated";
|
|
2
|
-
|
|
3
|
-
import { renderHook } from "@testing-library/react-hooks";
|
|
4
|
-
|
|
5
|
-
import type { IOpts } from "./useOffsetX";
|
|
6
|
-
import { useOffsetX } from "./useOffsetX";
|
|
7
|
-
import type { IVisibleRanges } from "./useVisibleRanges";
|
|
8
|
-
|
|
9
|
-
describe("useSharedValue", () => {
|
|
10
|
-
it("should return the correct values", async () => {
|
|
11
|
-
const hook = renderHook(() => {
|
|
12
|
-
const range = useSharedValue({
|
|
13
|
-
negativeRange: [7, 9],
|
|
14
|
-
positiveRange: [0, 3],
|
|
15
|
-
}) as IVisibleRanges;
|
|
16
|
-
const inputs: Array<{
|
|
17
|
-
config: IOpts;
|
|
18
|
-
range: IVisibleRanges;
|
|
19
|
-
}> = Array.from({ length: 10 }).map((_, index) => ({
|
|
20
|
-
config: {
|
|
21
|
-
dataLength: 10,
|
|
22
|
-
handlerOffset: useSharedValue(-0),
|
|
23
|
-
index,
|
|
24
|
-
loop: false,
|
|
25
|
-
size: 393,
|
|
26
|
-
},
|
|
27
|
-
range,
|
|
28
|
-
}));
|
|
29
|
-
|
|
30
|
-
return inputs.map((input) => {
|
|
31
|
-
const { config, range } = input;
|
|
32
|
-
|
|
33
|
-
return useOffsetX(config, range);
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
const expected = hook.result.current.map((v) => v.value).slice();
|
|
38
|
-
|
|
39
|
-
expect(expected).toMatchInlineSnapshot(`
|
|
40
|
-
[
|
|
41
|
-
0,
|
|
42
|
-
393,
|
|
43
|
-
786,
|
|
44
|
-
1179,
|
|
45
|
-
9007199254740991,
|
|
46
|
-
9007199254740991,
|
|
47
|
-
9007199254740991,
|
|
48
|
-
2751,
|
|
49
|
-
3144,
|
|
50
|
-
3537,
|
|
51
|
-
]
|
|
52
|
-
`);
|
|
53
|
-
});
|
|
54
|
-
});
|
|
@@ -1,270 +0,0 @@
|
|
|
1
|
-
import { useSharedValue } from "react-native-reanimated";
|
|
2
|
-
|
|
3
|
-
import { renderHook } from "@testing-library/react-hooks";
|
|
4
|
-
|
|
5
|
-
import { useOnProgressChange } from "./useOnProgressChange";
|
|
6
|
-
|
|
7
|
-
// Mock Reanimated and Easing
|
|
8
|
-
jest.mock("react-native-reanimated", () => {
|
|
9
|
-
const React = jest.requireActual("react");
|
|
10
|
-
let reactionCallback: ((value: any) => void) | null = null;
|
|
11
|
-
let reactionRegistrationCount = 0;
|
|
12
|
-
|
|
13
|
-
return {
|
|
14
|
-
useSharedValue: jest.fn((initialValue) => ({
|
|
15
|
-
value: initialValue,
|
|
16
|
-
})),
|
|
17
|
-
useAnimatedReaction: jest.fn((prepare, react, dependencies) => {
|
|
18
|
-
React.useEffect(() => {
|
|
19
|
-
reactionRegistrationCount += 1;
|
|
20
|
-
reactionCallback = react;
|
|
21
|
-
react(prepare());
|
|
22
|
-
return () => {
|
|
23
|
-
if (reactionCallback === react) reactionCallback = null;
|
|
24
|
-
};
|
|
25
|
-
}, dependencies);
|
|
26
|
-
}),
|
|
27
|
-
Easing: {
|
|
28
|
-
bezier: () => ({
|
|
29
|
-
factory: () => 0,
|
|
30
|
-
}),
|
|
31
|
-
},
|
|
32
|
-
// Export the helper function for testing
|
|
33
|
-
__triggerReaction: (value: any) => {
|
|
34
|
-
if (reactionCallback) reactionCallback(value);
|
|
35
|
-
},
|
|
36
|
-
__getReactionRegistrationCount: () => reactionRegistrationCount,
|
|
37
|
-
__resetReactionRegistrationCount: () => {
|
|
38
|
-
reactionRegistrationCount = 0;
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
jest.mock("react-native-worklets", () => {
|
|
44
|
-
const mockScheduleOnRN = jest.fn((fn, ...args) => fn(...args));
|
|
45
|
-
return {
|
|
46
|
-
scheduleOnRN: mockScheduleOnRN,
|
|
47
|
-
mockScheduleOnRN,
|
|
48
|
-
};
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
// Mock computedOffsetXValueWithAutoFillData
|
|
52
|
-
jest.mock("../utils/computed-with-auto-fill-data", () => ({
|
|
53
|
-
computedOffsetXValueWithAutoFillData: jest.fn(({ value }) => value),
|
|
54
|
-
}));
|
|
55
|
-
|
|
56
|
-
describe("useOnProgressChange", () => {
|
|
57
|
-
const mockOffsetX = useSharedValue(0);
|
|
58
|
-
const mockSizeReady = useSharedValue(true);
|
|
59
|
-
const mockOnProgressChange = jest.fn();
|
|
60
|
-
const { __getReactionRegistrationCount, __resetReactionRegistrationCount, __triggerReaction } =
|
|
61
|
-
jest.requireMock("react-native-reanimated");
|
|
62
|
-
|
|
63
|
-
beforeEach(() => {
|
|
64
|
-
jest.clearAllMocks();
|
|
65
|
-
__resetReactionRegistrationCount();
|
|
66
|
-
mockOffsetX.value = 0;
|
|
67
|
-
mockSizeReady.value = true;
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it("should handle progress change with function callback", () => {
|
|
71
|
-
renderHook(() =>
|
|
72
|
-
useOnProgressChange({
|
|
73
|
-
size: 300,
|
|
74
|
-
sizeReady: mockSizeReady,
|
|
75
|
-
autoFillData: false,
|
|
76
|
-
loop: false,
|
|
77
|
-
offsetX: mockOffsetX,
|
|
78
|
-
rawDataLength: 5,
|
|
79
|
-
onProgressChange: mockOnProgressChange,
|
|
80
|
-
})
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
mockOffsetX.value = -300; // Move to next slide
|
|
84
|
-
__triggerReaction({ offset: mockOffsetX.value, ready: mockSizeReady.value });
|
|
85
|
-
expect(mockOnProgressChange).toHaveBeenCalledWith(-300, 1);
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
it("should handle progress change with shared value", () => {
|
|
89
|
-
const progressValue = useSharedValue(0);
|
|
90
|
-
renderHook(() =>
|
|
91
|
-
useOnProgressChange({
|
|
92
|
-
size: 300,
|
|
93
|
-
sizeReady: mockSizeReady,
|
|
94
|
-
autoFillData: false,
|
|
95
|
-
loop: false,
|
|
96
|
-
offsetX: mockOffsetX,
|
|
97
|
-
rawDataLength: 5,
|
|
98
|
-
onProgressChange: progressValue,
|
|
99
|
-
})
|
|
100
|
-
);
|
|
101
|
-
|
|
102
|
-
mockOffsetX.value = -300; // Move to next slide
|
|
103
|
-
__triggerReaction({ offset: mockOffsetX.value, ready: mockSizeReady.value });
|
|
104
|
-
expect(progressValue.value).toBe(1);
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it("should handle loop mode", () => {
|
|
108
|
-
renderHook(() =>
|
|
109
|
-
useOnProgressChange({
|
|
110
|
-
size: 300,
|
|
111
|
-
sizeReady: mockSizeReady,
|
|
112
|
-
autoFillData: false,
|
|
113
|
-
loop: true,
|
|
114
|
-
offsetX: mockOffsetX,
|
|
115
|
-
rawDataLength: 5,
|
|
116
|
-
onProgressChange: mockOnProgressChange,
|
|
117
|
-
})
|
|
118
|
-
);
|
|
119
|
-
|
|
120
|
-
mockOffsetX.value = -1500; // Move to last slide
|
|
121
|
-
__triggerReaction({ offset: mockOffsetX.value, ready: mockSizeReady.value });
|
|
122
|
-
expect(mockOnProgressChange).toHaveBeenCalledWith(-1500, 5);
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
it("should handle autoFillData mode", () => {
|
|
126
|
-
renderHook(() =>
|
|
127
|
-
useOnProgressChange({
|
|
128
|
-
size: 300,
|
|
129
|
-
sizeReady: mockSizeReady,
|
|
130
|
-
autoFillData: true,
|
|
131
|
-
loop: false,
|
|
132
|
-
offsetX: mockOffsetX,
|
|
133
|
-
rawDataLength: 3,
|
|
134
|
-
onProgressChange: mockOnProgressChange,
|
|
135
|
-
})
|
|
136
|
-
);
|
|
137
|
-
|
|
138
|
-
mockOffsetX.value = -300; // Move to next slide
|
|
139
|
-
__triggerReaction({ offset: mockOffsetX.value, ready: mockSizeReady.value });
|
|
140
|
-
expect(mockOnProgressChange).toHaveBeenCalledWith(-300, 1);
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
it("should clamp values when not in loop mode", () => {
|
|
144
|
-
renderHook(() =>
|
|
145
|
-
useOnProgressChange({
|
|
146
|
-
size: 300,
|
|
147
|
-
sizeReady: mockSizeReady,
|
|
148
|
-
autoFillData: false,
|
|
149
|
-
loop: false,
|
|
150
|
-
offsetX: mockOffsetX,
|
|
151
|
-
rawDataLength: 3,
|
|
152
|
-
onProgressChange: mockOnProgressChange,
|
|
153
|
-
})
|
|
154
|
-
);
|
|
155
|
-
|
|
156
|
-
mockOffsetX.value = 300; // Try to move before first slide
|
|
157
|
-
__triggerReaction({ offset: mockOffsetX.value, ready: mockSizeReady.value });
|
|
158
|
-
expect(mockOnProgressChange).toHaveBeenCalledWith(0, 0);
|
|
159
|
-
|
|
160
|
-
mockOffsetX.value = -900; // Try to move after last slide
|
|
161
|
-
__triggerReaction({ offset: mockOffsetX.value, ready: mockSizeReady.value });
|
|
162
|
-
expect(mockOnProgressChange).toHaveBeenCalledWith(-600, 2);
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
it("should handle positive offset values", () => {
|
|
166
|
-
renderHook(() =>
|
|
167
|
-
useOnProgressChange({
|
|
168
|
-
size: 300,
|
|
169
|
-
sizeReady: mockSizeReady,
|
|
170
|
-
autoFillData: false,
|
|
171
|
-
loop: true,
|
|
172
|
-
offsetX: mockOffsetX,
|
|
173
|
-
rawDataLength: 5,
|
|
174
|
-
onProgressChange: mockOnProgressChange,
|
|
175
|
-
})
|
|
176
|
-
);
|
|
177
|
-
|
|
178
|
-
mockOffsetX.value = 300; // Move backwards
|
|
179
|
-
__triggerReaction({ offset: mockOffsetX.value, ready: mockSizeReady.value });
|
|
180
|
-
expect(mockOnProgressChange).toHaveBeenCalledWith(300, 4);
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
it("should not call onProgressChange if not provided", () => {
|
|
184
|
-
renderHook(() =>
|
|
185
|
-
useOnProgressChange({
|
|
186
|
-
size: 300,
|
|
187
|
-
sizeReady: mockSizeReady,
|
|
188
|
-
autoFillData: false,
|
|
189
|
-
loop: false,
|
|
190
|
-
offsetX: mockOffsetX,
|
|
191
|
-
rawDataLength: 5,
|
|
192
|
-
})
|
|
193
|
-
);
|
|
194
|
-
|
|
195
|
-
mockOffsetX.value = -300; // Move to next slide
|
|
196
|
-
__triggerReaction({ offset: mockOffsetX.value, ready: mockSizeReady.value });
|
|
197
|
-
// Should not throw any errors or call any callbacks
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
it("should not trigger progress change when size is not ready", () => {
|
|
201
|
-
const mockSizeNotReady = useSharedValue(false);
|
|
202
|
-
renderHook(() =>
|
|
203
|
-
useOnProgressChange({
|
|
204
|
-
size: 300,
|
|
205
|
-
sizeReady: mockSizeNotReady,
|
|
206
|
-
autoFillData: false,
|
|
207
|
-
loop: false,
|
|
208
|
-
offsetX: mockOffsetX,
|
|
209
|
-
rawDataLength: 5,
|
|
210
|
-
onProgressChange: mockOnProgressChange,
|
|
211
|
-
})
|
|
212
|
-
);
|
|
213
|
-
|
|
214
|
-
mockOffsetX.value = -300; // Move to next slide
|
|
215
|
-
__triggerReaction({ offset: mockOffsetX.value, ready: mockSizeNotReady.value });
|
|
216
|
-
expect(mockOnProgressChange).not.toHaveBeenCalled();
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
it("should re-register the reaction when the offset shared value changes", () => {
|
|
220
|
-
const replacementOffsetX = useSharedValue(-300);
|
|
221
|
-
const { rerender } = renderHook(
|
|
222
|
-
({ offsetX }) =>
|
|
223
|
-
useOnProgressChange({
|
|
224
|
-
size: 300,
|
|
225
|
-
sizeReady: mockSizeReady,
|
|
226
|
-
autoFillData: false,
|
|
227
|
-
loop: false,
|
|
228
|
-
offsetX,
|
|
229
|
-
rawDataLength: 5,
|
|
230
|
-
onProgressChange: mockOnProgressChange,
|
|
231
|
-
}),
|
|
232
|
-
{ initialProps: { offsetX: mockOffsetX } }
|
|
233
|
-
);
|
|
234
|
-
|
|
235
|
-
const initialRegistrationCount = __getReactionRegistrationCount();
|
|
236
|
-
rerender({ offsetX: mockOffsetX });
|
|
237
|
-
expect(__getReactionRegistrationCount()).toBe(initialRegistrationCount);
|
|
238
|
-
|
|
239
|
-
rerender({ offsetX: replacementOffsetX });
|
|
240
|
-
|
|
241
|
-
expect(__getReactionRegistrationCount()).toBe(initialRegistrationCount + 1);
|
|
242
|
-
expect(mockOnProgressChange).toHaveBeenLastCalledWith(-300, 1);
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
it("should re-register the reaction when the size-ready shared value changes", () => {
|
|
246
|
-
const initialSizeReady = useSharedValue(false);
|
|
247
|
-
const replacementSizeReady = useSharedValue(true);
|
|
248
|
-
const { rerender } = renderHook(
|
|
249
|
-
({ sizeReady }) =>
|
|
250
|
-
useOnProgressChange({
|
|
251
|
-
size: 300,
|
|
252
|
-
sizeReady,
|
|
253
|
-
autoFillData: false,
|
|
254
|
-
loop: false,
|
|
255
|
-
offsetX: mockOffsetX,
|
|
256
|
-
rawDataLength: 5,
|
|
257
|
-
onProgressChange: mockOnProgressChange,
|
|
258
|
-
}),
|
|
259
|
-
{ initialProps: { sizeReady: initialSizeReady } }
|
|
260
|
-
);
|
|
261
|
-
|
|
262
|
-
const initialRegistrationCount = __getReactionRegistrationCount();
|
|
263
|
-
expect(mockOnProgressChange).not.toHaveBeenCalled();
|
|
264
|
-
|
|
265
|
-
rerender({ sizeReady: replacementSizeReady });
|
|
266
|
-
|
|
267
|
-
expect(__getReactionRegistrationCount()).toBe(initialRegistrationCount + 1);
|
|
268
|
-
expect(mockOnProgressChange).toHaveBeenCalledWith(0, 0);
|
|
269
|
-
});
|
|
270
|
-
});
|