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,178 +0,0 @@
|
|
|
1
|
-
import { act, fireEvent, render } from "@testing-library/react-native";
|
|
2
|
-
import { View } from "react-native";
|
|
3
|
-
import { useSharedValue } from "react-native-reanimated";
|
|
4
|
-
|
|
5
|
-
import { Pagination } from ".";
|
|
6
|
-
|
|
7
|
-
jest.mock("react-native-worklets", () => ({
|
|
8
|
-
scheduleOnRN: (fn: (...args: unknown[]) => void, ...args: unknown[]) => fn(...args),
|
|
9
|
-
}));
|
|
10
|
-
|
|
11
|
-
// Use fake timers so the reanimated mapper's mockedRequestAnimationFrame
|
|
12
|
-
// (a setTimeout-based RAF) doesn't fire outside of act().
|
|
13
|
-
beforeEach(() => {
|
|
14
|
-
jest.useFakeTimers();
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
afterEach(() => {
|
|
18
|
-
jest.useRealTimers();
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
describe("Pagination.Basic", () => {
|
|
22
|
-
it("throws when size/dot width/height are non-number", () => {
|
|
23
|
-
const Test = () => {
|
|
24
|
-
const progress = useSharedValue(0);
|
|
25
|
-
return (
|
|
26
|
-
<Pagination.Basic
|
|
27
|
-
data={[1, 2]}
|
|
28
|
-
progress={progress}
|
|
29
|
-
// @ts-expect-error intentional invalid type
|
|
30
|
-
size={"12px"}
|
|
31
|
-
/>
|
|
32
|
-
);
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
expect(() => render(<Test />)).toThrow("size/width/height must be a number");
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it("renders dots and calls onPress", async () => {
|
|
39
|
-
const handlePress = jest.fn();
|
|
40
|
-
const Test = () => {
|
|
41
|
-
const progress = useSharedValue(0);
|
|
42
|
-
return (
|
|
43
|
-
<Pagination.Basic
|
|
44
|
-
data={[1, 2, 3]}
|
|
45
|
-
progress={progress}
|
|
46
|
-
onPress={handlePress}
|
|
47
|
-
carouselName="Demo"
|
|
48
|
-
/>
|
|
49
|
-
);
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const { UNSAFE_root } = render(<Test />);
|
|
53
|
-
await act(async () => {
|
|
54
|
-
jest.advanceTimersByTime(100);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
const buttons = UNSAFE_root.findAll(
|
|
58
|
-
(node) =>
|
|
59
|
-
node?.props?.accessibilityRole === "button" &&
|
|
60
|
-
typeof node?.props?.accessibilityLabel === "string" &&
|
|
61
|
-
node.props.accessibilityLabel.startsWith("Slide ")
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
const uniqueByLabel = Array.from(
|
|
65
|
-
new Map(buttons.map((b) => [b.props.accessibilityLabel, b])).values()
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
expect(uniqueByLabel).toHaveLength(3);
|
|
69
|
-
|
|
70
|
-
await act(async () => {
|
|
71
|
-
fireEvent.press(uniqueByLabel[1]);
|
|
72
|
-
jest.advanceTimersByTime(100);
|
|
73
|
-
});
|
|
74
|
-
expect(handlePress).toHaveBeenCalledWith(1);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it("does not include undefined in default accessibilityLabel when carouselName is omitted", async () => {
|
|
78
|
-
const Test = () => {
|
|
79
|
-
const progress = useSharedValue(0);
|
|
80
|
-
return <Pagination.Basic data={[1, 2]} progress={progress} />;
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
const { UNSAFE_root } = render(<Test />);
|
|
84
|
-
await act(async () => {
|
|
85
|
-
jest.advanceTimersByTime(100);
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
const buttons = UNSAFE_root.findAll(
|
|
89
|
-
(node) =>
|
|
90
|
-
node?.props?.accessibilityRole === "button" &&
|
|
91
|
-
typeof node?.props?.accessibilityLabel === "string" &&
|
|
92
|
-
node.props.accessibilityLabel.startsWith("Slide ")
|
|
93
|
-
);
|
|
94
|
-
|
|
95
|
-
const uniqueByLabel = Array.from(
|
|
96
|
-
new Map(buttons.map((b) => [b.props.accessibilityLabel, b])).values()
|
|
97
|
-
);
|
|
98
|
-
|
|
99
|
-
expect(uniqueByLabel[0].props.accessibilityLabel).toBe("Slide 1 of 2");
|
|
100
|
-
expect(uniqueByLabel[0].props.accessibilityLabel).not.toContain("undefined");
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
describe("Pagination.Custom", () => {
|
|
105
|
-
it("throws when any size-related prop is non-number", () => {
|
|
106
|
-
const Test = () => {
|
|
107
|
-
const progress = useSharedValue(0);
|
|
108
|
-
return (
|
|
109
|
-
<Pagination.Custom
|
|
110
|
-
data={[1]}
|
|
111
|
-
progress={progress}
|
|
112
|
-
// @ts-expect-error intentional invalid type
|
|
113
|
-
activeDotStyle={{ width: "10px" }}
|
|
114
|
-
/>
|
|
115
|
-
);
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
expect(() => render(<Test />)).toThrow("size/width/height must be a number");
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
it("uses max item dimensions for container min sizes", async () => {
|
|
122
|
-
const Test = () => {
|
|
123
|
-
const progress = useSharedValue(0);
|
|
124
|
-
return (
|
|
125
|
-
<Pagination.Custom
|
|
126
|
-
data={[1, 2]}
|
|
127
|
-
progress={progress}
|
|
128
|
-
size={12}
|
|
129
|
-
dotStyle={{ width: 14, height: 8 }}
|
|
130
|
-
activeDotStyle={{ width: 16, height: 20 }}
|
|
131
|
-
/>
|
|
132
|
-
);
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
const { UNSAFE_root } = render(<Test />);
|
|
136
|
-
await act(async () => {
|
|
137
|
-
jest.advanceTimersByTime(100);
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
// @ts-expect-error
|
|
141
|
-
const container = UNSAFE_root.findByType(View);
|
|
142
|
-
const flattened = Array.isArray(container.props.style)
|
|
143
|
-
? Object.assign({}, ...container.props.style.filter(Boolean))
|
|
144
|
-
: container.props.style;
|
|
145
|
-
|
|
146
|
-
expect(flattened.minWidth).toBe(16);
|
|
147
|
-
expect(flattened.minHeight).toBe(20);
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
it("allows overriding pagination item accessibility props", async () => {
|
|
151
|
-
const Test = () => {
|
|
152
|
-
const progress = useSharedValue(0);
|
|
153
|
-
return (
|
|
154
|
-
<Pagination.Custom
|
|
155
|
-
data={[1, 2]}
|
|
156
|
-
progress={progress}
|
|
157
|
-
paginationItemAccessibility={(index: number, length: number) => ({
|
|
158
|
-
accessibilityLabel: `Page ${index + 1}/${length}`,
|
|
159
|
-
accessibilityHint: `Jump to ${index + 1}`,
|
|
160
|
-
accessibilityRole: "link",
|
|
161
|
-
})}
|
|
162
|
-
/>
|
|
163
|
-
);
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
const { UNSAFE_root } = render(<Test />);
|
|
167
|
-
await act(async () => {
|
|
168
|
-
jest.advanceTimersByTime(100);
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
const item = UNSAFE_root.find(
|
|
172
|
-
(node) =>
|
|
173
|
-
node?.props?.accessibilityLabel === "Page 1/2" && node?.props?.accessibilityRole === "link"
|
|
174
|
-
);
|
|
175
|
-
|
|
176
|
-
expect(item.props.accessibilityHint).toBe("Jump to 1");
|
|
177
|
-
});
|
|
178
|
-
});
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { View } from "react-native";
|
|
3
|
-
import type {
|
|
4
|
-
GestureStateChangeEvent,
|
|
5
|
-
GestureUpdateEvent,
|
|
6
|
-
PanGestureHandlerEventPayload,
|
|
7
|
-
} from "react-native-gesture-handler";
|
|
8
|
-
import type { SharedValue } from "react-native-reanimated";
|
|
9
|
-
|
|
10
|
-
import { act, render } from "@testing-library/react-native";
|
|
11
|
-
|
|
12
|
-
import { ScrollViewGesture } from "./ScrollViewGesture";
|
|
13
|
-
|
|
14
|
-
import { usePanGestureProxy } from "../hooks/usePanGestureProxy";
|
|
15
|
-
import { GlobalStateContext, type IContext } from "../store";
|
|
16
|
-
|
|
17
|
-
jest.mock("../hooks/usePanGestureProxy", () => ({
|
|
18
|
-
usePanGestureProxy: jest.fn(() => ({})),
|
|
19
|
-
}));
|
|
20
|
-
|
|
21
|
-
const mockUsePanGestureProxy = jest.mocked(usePanGestureProxy);
|
|
22
|
-
|
|
23
|
-
jest.mock("react-native-gesture-handler", () => {
|
|
24
|
-
const React = require("react");
|
|
25
|
-
const actual = jest.requireActual("react-native-gesture-handler");
|
|
26
|
-
|
|
27
|
-
return {
|
|
28
|
-
...actual,
|
|
29
|
-
GestureDetector: ({ children }: { children: React.ReactNode }) => {
|
|
30
|
-
const child = React.Children.only(children);
|
|
31
|
-
|
|
32
|
-
// Simulate the upstream web path that reads `element.ref`.
|
|
33
|
-
// React 19 warns only when the child element actually carries a ref.
|
|
34
|
-
// @ts-expect-error React 19 removed `element.ref` from the element type.
|
|
35
|
-
void child.ref;
|
|
36
|
-
|
|
37
|
-
return child;
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
type RenderGestureOptions = {
|
|
43
|
-
vertical?: boolean;
|
|
44
|
-
size?: number;
|
|
45
|
-
dataLength?: number;
|
|
46
|
-
containerSize?: { width: number; height: number };
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
function renderGesture({
|
|
50
|
-
vertical = false,
|
|
51
|
-
size = 300,
|
|
52
|
-
dataLength = 3,
|
|
53
|
-
containerSize = { width: 300, height: 200 },
|
|
54
|
-
}: RenderGestureOptions = {}) {
|
|
55
|
-
const translation = { value: 0 } as SharedValue<number>;
|
|
56
|
-
const contextValue = {
|
|
57
|
-
props: {
|
|
58
|
-
onConfigurePanGesture: undefined,
|
|
59
|
-
vertical,
|
|
60
|
-
pagingEnabled: true,
|
|
61
|
-
snapEnabled: true,
|
|
62
|
-
loop: false,
|
|
63
|
-
scrollAnimationDuration: 500,
|
|
64
|
-
withAnimation: undefined,
|
|
65
|
-
enabled: true,
|
|
66
|
-
dataLength,
|
|
67
|
-
overscrollEnabled: false,
|
|
68
|
-
maxScrollDistancePerSwipe: undefined,
|
|
69
|
-
minScrollDistancePerSwipe: undefined,
|
|
70
|
-
fixedDirection: undefined,
|
|
71
|
-
},
|
|
72
|
-
common: {
|
|
73
|
-
size,
|
|
74
|
-
validLength: dataLength,
|
|
75
|
-
handlerOffset: { value: 0 },
|
|
76
|
-
resolvedSize: { value: size },
|
|
77
|
-
sizePhase: { value: "ready" },
|
|
78
|
-
sizeExplicit: true,
|
|
79
|
-
},
|
|
80
|
-
layout: {
|
|
81
|
-
containerSize: { value: containerSize },
|
|
82
|
-
updateContainerSize: jest.fn(),
|
|
83
|
-
itemDimensions: { value: {} },
|
|
84
|
-
updateItemDimensions: jest.fn(),
|
|
85
|
-
},
|
|
86
|
-
} as unknown as IContext;
|
|
87
|
-
|
|
88
|
-
render(
|
|
89
|
-
<GlobalStateContext.Provider value={contextValue}>
|
|
90
|
-
<ScrollViewGesture size={size} translation={translation} style={containerSize}>
|
|
91
|
-
<View testID="content" />
|
|
92
|
-
</ScrollViewGesture>
|
|
93
|
-
</GlobalStateContext.Provider>
|
|
94
|
-
);
|
|
95
|
-
|
|
96
|
-
const gestureCallbacks =
|
|
97
|
-
mockUsePanGestureProxy.mock.calls[mockUsePanGestureProxy.mock.calls.length - 1]?.[0];
|
|
98
|
-
|
|
99
|
-
if (!gestureCallbacks) {
|
|
100
|
-
throw new Error("Expected ScrollViewGesture to configure the pan gesture");
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return { gestureCallbacks, translation };
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
describe("issue #857 web regression", () => {
|
|
107
|
-
beforeEach(() => {
|
|
108
|
-
mockUsePanGestureProxy.mockClear();
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it("does not emit the React 19 element.ref warning from the gesture path", () => {
|
|
112
|
-
const errorSpy = jest.spyOn(console, "error").mockImplementation(() => {});
|
|
113
|
-
|
|
114
|
-
try {
|
|
115
|
-
renderGesture();
|
|
116
|
-
|
|
117
|
-
const react19RefWarnings = errorSpy.mock.calls.filter(([message]) =>
|
|
118
|
-
String(message).includes("Accessing element.ref was removed in React 19")
|
|
119
|
-
);
|
|
120
|
-
|
|
121
|
-
expect(react19RefWarnings).toHaveLength(0);
|
|
122
|
-
} finally {
|
|
123
|
-
errorSpy.mockRestore();
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
it.each([
|
|
128
|
-
["horizontal", false, 300, 3, { width: 300, height: 200 }, -600],
|
|
129
|
-
["vertical", true, 300, 3, { width: 300, height: 200 }, -700],
|
|
130
|
-
["unmeasured container", false, 300, 3, { width: 0, height: 0 }, 0],
|
|
131
|
-
["content smaller than its container", false, 100, 2, { width: 300, height: 200 }, 0],
|
|
132
|
-
] as const)(
|
|
133
|
-
"uses the %s main-axis container size for the non-loop boundary",
|
|
134
|
-
(_name, vertical, size, dataLength, containerSize, expectedTranslation) => {
|
|
135
|
-
const { gestureCallbacks, translation } = renderGesture({
|
|
136
|
-
vertical,
|
|
137
|
-
size,
|
|
138
|
-
dataLength,
|
|
139
|
-
containerSize,
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
act(() => {
|
|
143
|
-
gestureCallbacks.onGestureStart(
|
|
144
|
-
{} as GestureStateChangeEvent<PanGestureHandlerEventPayload>
|
|
145
|
-
);
|
|
146
|
-
gestureCallbacks.onGestureUpdate({
|
|
147
|
-
translationX: -1000,
|
|
148
|
-
translationY: -1000,
|
|
149
|
-
} as GestureUpdateEvent<PanGestureHandlerEventPayload>);
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
expect(translation.value).toBeCloseTo(expectedTranslation);
|
|
153
|
-
}
|
|
154
|
-
);
|
|
155
|
-
});
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { StyleSheet } from "react-native";
|
|
3
|
-
import type { PanGesture } from "react-native-gesture-handler";
|
|
4
|
-
import { Gesture, State } from "react-native-gesture-handler";
|
|
5
|
-
import Animated, { useDerivedValue, useSharedValue } from "react-native-reanimated";
|
|
6
|
-
|
|
7
|
-
import { act, render, waitFor } from "@testing-library/react-native";
|
|
8
|
-
import { fireGestureHandler, getByGestureTestId } from "react-native-gesture-handler/jest-utils";
|
|
9
|
-
|
|
10
|
-
import Carousel from "./Carousel";
|
|
11
|
-
|
|
12
|
-
{
|
|
13
|
-
const cfg = (global as any).__reanimatedLoggerConfig as
|
|
14
|
-
| { logFunction: (data: { level: number; message: string }) => void }
|
|
15
|
-
| undefined;
|
|
16
|
-
if (cfg) {
|
|
17
|
-
const originalLog = cfg.logFunction;
|
|
18
|
-
cfg.logFunction = (data) => {
|
|
19
|
-
if (data.message.includes("measure() cannot be used with Jest")) return;
|
|
20
|
-
originalLog(data);
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const slideWidth = 300;
|
|
26
|
-
const slideHeight = 200;
|
|
27
|
-
const gestureTestId = "rnrc-gesture-handler";
|
|
28
|
-
const realPan = Gesture.Pan();
|
|
29
|
-
|
|
30
|
-
jest.spyOn(Gesture, "Pan").mockImplementation(() => realPan.withTestId(gestureTestId));
|
|
31
|
-
|
|
32
|
-
describe("issue #899 parallax reverse loop regression", () => {
|
|
33
|
-
beforeEach(() => {
|
|
34
|
-
jest.useFakeTimers();
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
afterEach(() => {
|
|
38
|
-
act(() => {
|
|
39
|
-
jest.runOnlyPendingTimers();
|
|
40
|
-
});
|
|
41
|
-
jest.useRealTimers();
|
|
42
|
-
jest.clearAllTimers();
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it("preserves renderItem styles and props when looping backward from index 0 in parallax mode", async () => {
|
|
46
|
-
const progress = { current: 0 };
|
|
47
|
-
const data = Array.from({ length: 30 }, (_, index) => ({
|
|
48
|
-
id: `item-${index}`,
|
|
49
|
-
color: index === 29 ? "#111111" : `rgb(${index}, ${index}, ${index})`,
|
|
50
|
-
}));
|
|
51
|
-
|
|
52
|
-
const Wrapper = () => {
|
|
53
|
-
const progressAnimVal = useSharedValue(progress.current);
|
|
54
|
-
|
|
55
|
-
useDerivedValue(() => {
|
|
56
|
-
progress.current = progressAnimVal.value;
|
|
57
|
-
}, [progressAnimVal]);
|
|
58
|
-
|
|
59
|
-
return (
|
|
60
|
-
<Carousel
|
|
61
|
-
data={data}
|
|
62
|
-
defaultIndex={0}
|
|
63
|
-
loop
|
|
64
|
-
mode="parallax"
|
|
65
|
-
windowSize={5}
|
|
66
|
-
style={{ width: slideWidth, height: slideHeight }}
|
|
67
|
-
onProgressChange={(_, absoluteProgress) => {
|
|
68
|
-
progressAnimVal.value = absoluteProgress;
|
|
69
|
-
}}
|
|
70
|
-
renderItem={({ item, index }) => (
|
|
71
|
-
<Animated.View
|
|
72
|
-
testID={`issue-899-item-${index}`}
|
|
73
|
-
accessibilityLabel={`issue-899-label-${index}`}
|
|
74
|
-
style={{
|
|
75
|
-
width: slideWidth,
|
|
76
|
-
height: slideHeight,
|
|
77
|
-
backgroundColor: item.color,
|
|
78
|
-
}}
|
|
79
|
-
/>
|
|
80
|
-
)}
|
|
81
|
-
/>
|
|
82
|
-
);
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
const { getByTestId, queryByTestId } = render(<Wrapper />);
|
|
86
|
-
|
|
87
|
-
await waitFor(() => {
|
|
88
|
-
expect(getByTestId("issue-899-item-0")).toBeTruthy();
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
const prerenderedWrappedItem = getByTestId("issue-899-item-29");
|
|
92
|
-
const prerenderedWrappedStyle = StyleSheet.flatten(prerenderedWrappedItem.props.style);
|
|
93
|
-
|
|
94
|
-
expect(prerenderedWrappedItem.props.accessibilityLabel).toBe("issue-899-label-29");
|
|
95
|
-
expect(prerenderedWrappedStyle.backgroundColor).toBe("#111111");
|
|
96
|
-
|
|
97
|
-
fireGestureHandler<PanGesture>(getByGestureTestId(gestureTestId), [
|
|
98
|
-
{ state: State.BEGAN, translationX: 0, velocityX: slideWidth },
|
|
99
|
-
]);
|
|
100
|
-
|
|
101
|
-
fireGestureHandler<PanGesture>(getByGestureTestId(gestureTestId), [
|
|
102
|
-
{ state: State.ACTIVE, translationX: slideWidth * 0.7, velocityX: slideWidth },
|
|
103
|
-
]);
|
|
104
|
-
|
|
105
|
-
expect(queryByTestId("issue-899-item-29")).toBeTruthy();
|
|
106
|
-
|
|
107
|
-
await waitFor(() => {
|
|
108
|
-
expect(queryByTestId("issue-899-item-29")).toBeTruthy();
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
const activeWrappedItem = getByTestId("issue-899-item-29");
|
|
112
|
-
const activeWrappedStyle = StyleSheet.flatten(activeWrappedItem.props.style);
|
|
113
|
-
|
|
114
|
-
expect(activeWrappedItem.props.accessibilityLabel).toBe("issue-899-label-29");
|
|
115
|
-
expect(activeWrappedStyle.backgroundColor).toBe("#111111");
|
|
116
|
-
|
|
117
|
-
fireGestureHandler<PanGesture>(getByGestureTestId(gestureTestId), [
|
|
118
|
-
{ state: State.END, translationX: slideWidth, velocityX: slideWidth },
|
|
119
|
-
]);
|
|
120
|
-
|
|
121
|
-
await waitFor(() => {
|
|
122
|
-
expect(progress.current).toBe(29);
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
const wrappedItem = getByTestId("issue-899-item-29");
|
|
126
|
-
const flattenedStyle = StyleSheet.flatten(wrappedItem.props.style);
|
|
127
|
-
|
|
128
|
-
expect(wrappedItem.props.accessibilityLabel).toBe("issue-899-label-29");
|
|
129
|
-
expect(flattenedStyle.backgroundColor).toBe("#111111");
|
|
130
|
-
});
|
|
131
|
-
});
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { render } from "@testing-library/react-native";
|
|
2
|
-
import type { FC } from "react";
|
|
3
|
-
import React from "react";
|
|
4
|
-
import Animated, { useAnimatedStyle, useSharedValue, withTiming } from "react-native-reanimated";
|
|
5
|
-
|
|
6
|
-
describe("Carousel Animations", () => {
|
|
7
|
-
beforeEach(() => {
|
|
8
|
-
jest.useFakeTimers();
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
afterEach(() => {
|
|
12
|
-
jest.runOnlyPendingTimers();
|
|
13
|
-
jest.useRealTimers();
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it("animates opacity with timing", () => {
|
|
17
|
-
const TestComponent: FC<{ value: number }> = ({ value }) => {
|
|
18
|
-
const sharedValue = useSharedValue(value);
|
|
19
|
-
|
|
20
|
-
// Using withTiming to wrap the value change, so it can be tested
|
|
21
|
-
const animatedStyle = useAnimatedStyle(() => ({
|
|
22
|
-
opacity: withTiming(sharedValue.value, { duration: 500 }),
|
|
23
|
-
}));
|
|
24
|
-
|
|
25
|
-
// When the prop changes, update the shared value
|
|
26
|
-
React.useEffect(() => {
|
|
27
|
-
sharedValue.value = value;
|
|
28
|
-
}, [value, sharedValue]);
|
|
29
|
-
|
|
30
|
-
return <Animated.View testID="animated-view" style={animatedStyle} />;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const initialValue = 0;
|
|
34
|
-
const updatedValue = 1;
|
|
35
|
-
|
|
36
|
-
const { getByTestId, rerender } = render(<TestComponent value={initialValue} />);
|
|
37
|
-
const view = getByTestId("animated-view");
|
|
38
|
-
|
|
39
|
-
// Verify the initial state
|
|
40
|
-
expect(view).toHaveAnimatedStyle({ opacity: initialValue });
|
|
41
|
-
|
|
42
|
-
// Trigger the value change
|
|
43
|
-
rerender(<TestComponent value={updatedValue} />);
|
|
44
|
-
|
|
45
|
-
// Advance the animation to the middle point
|
|
46
|
-
jest.advanceTimersByTime(250);
|
|
47
|
-
expect(view).toHaveAnimatedStyle({ opacity: 0.5 }); // Animation middle value
|
|
48
|
-
|
|
49
|
-
// Advance the animation to the completion
|
|
50
|
-
jest.advanceTimersByTime(250);
|
|
51
|
-
expect(view).toHaveAnimatedStyle({ opacity: updatedValue }); // Animation completion
|
|
52
|
-
});
|
|
53
|
-
});
|
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
import { act, renderHook } from "@testing-library/react-hooks";
|
|
2
|
-
|
|
3
|
-
import { useAutoPlay } from "./useAutoPlay";
|
|
4
|
-
|
|
5
|
-
describe("useAutoPlay", () => {
|
|
6
|
-
// Mock timer
|
|
7
|
-
beforeEach(() => {
|
|
8
|
-
jest.useFakeTimers();
|
|
9
|
-
jest.clearAllMocks();
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
afterEach(() => {
|
|
13
|
-
jest.clearAllTimers();
|
|
14
|
-
jest.useRealTimers();
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
// Mock carousel controller
|
|
18
|
-
const mockCarouselController = {
|
|
19
|
-
prev: jest.fn(),
|
|
20
|
-
next: jest.fn(),
|
|
21
|
-
getCurrentIndex: jest.fn(),
|
|
22
|
-
getSharedIndex: jest.fn(),
|
|
23
|
-
scrollTo: jest.fn(),
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
it("should start autoplay when autoPlay is true", () => {
|
|
27
|
-
renderHook(() =>
|
|
28
|
-
useAutoPlay({
|
|
29
|
-
autoPlay: true,
|
|
30
|
-
autoPlayInterval: 1000,
|
|
31
|
-
carouselController: mockCarouselController,
|
|
32
|
-
})
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
act(() => {
|
|
36
|
-
jest.runOnlyPendingTimers();
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
expect(mockCarouselController.next).toHaveBeenCalledTimes(1);
|
|
40
|
-
expect(mockCarouselController.next).toHaveBeenCalledWith(
|
|
41
|
-
expect.objectContaining({
|
|
42
|
-
onFinished: expect.any(Function),
|
|
43
|
-
})
|
|
44
|
-
);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it("should not start autoplay when autoPlay is false", () => {
|
|
48
|
-
renderHook(() =>
|
|
49
|
-
useAutoPlay({
|
|
50
|
-
autoPlay: false,
|
|
51
|
-
autoPlayInterval: 1000,
|
|
52
|
-
carouselController: mockCarouselController,
|
|
53
|
-
})
|
|
54
|
-
);
|
|
55
|
-
|
|
56
|
-
act(() => {
|
|
57
|
-
jest.runOnlyPendingTimers();
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
expect(mockCarouselController.next).not.toHaveBeenCalled();
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it("should play in reverse when autoPlayReverse is true", () => {
|
|
64
|
-
renderHook(() =>
|
|
65
|
-
useAutoPlay({
|
|
66
|
-
autoPlay: true,
|
|
67
|
-
autoPlayReverse: true,
|
|
68
|
-
autoPlayInterval: 1000,
|
|
69
|
-
carouselController: mockCarouselController,
|
|
70
|
-
})
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
act(() => {
|
|
74
|
-
jest.runOnlyPendingTimers();
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
expect(mockCarouselController.prev).toHaveBeenCalledTimes(1);
|
|
78
|
-
expect(mockCarouselController.next).not.toHaveBeenCalled();
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it("should clear timer on unmount", () => {
|
|
82
|
-
const { unmount } = renderHook(() =>
|
|
83
|
-
useAutoPlay({
|
|
84
|
-
autoPlay: true,
|
|
85
|
-
autoPlayInterval: 1000,
|
|
86
|
-
carouselController: mockCarouselController,
|
|
87
|
-
})
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
// Run the timer once to ensure it's set
|
|
91
|
-
act(() => {
|
|
92
|
-
jest.runOnlyPendingTimers();
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
// Clear previous call records
|
|
96
|
-
mockCarouselController.next.mockClear();
|
|
97
|
-
|
|
98
|
-
// Then unmount the component and run the timer again
|
|
99
|
-
act(() => {
|
|
100
|
-
unmount();
|
|
101
|
-
jest.runOnlyPendingTimers();
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
expect(mockCarouselController.next).not.toHaveBeenCalled();
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it("should pause and resume autoplay", () => {
|
|
108
|
-
const { result } = renderHook(() =>
|
|
109
|
-
useAutoPlay({
|
|
110
|
-
autoPlay: true,
|
|
111
|
-
autoPlayInterval: 1000,
|
|
112
|
-
carouselController: mockCarouselController,
|
|
113
|
-
})
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
// Run the timer once to ensure it's set
|
|
117
|
-
act(() => {
|
|
118
|
-
jest.runOnlyPendingTimers();
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
// Clear previous call records
|
|
122
|
-
mockCarouselController.next.mockClear();
|
|
123
|
-
|
|
124
|
-
// Pause autoplay
|
|
125
|
-
act(() => {
|
|
126
|
-
result.current.pause();
|
|
127
|
-
jest.runOnlyPendingTimers();
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
expect(mockCarouselController.next).not.toHaveBeenCalled();
|
|
131
|
-
|
|
132
|
-
// Resume autoplay
|
|
133
|
-
act(() => {
|
|
134
|
-
result.current.start();
|
|
135
|
-
jest.runOnlyPendingTimers();
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
expect(mockCarouselController.next).toHaveBeenCalledTimes(1);
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
it("should respect autoPlayInterval timing", () => {
|
|
142
|
-
renderHook(() =>
|
|
143
|
-
useAutoPlay({
|
|
144
|
-
autoPlay: true,
|
|
145
|
-
autoPlayInterval: 2000,
|
|
146
|
-
carouselController: mockCarouselController,
|
|
147
|
-
})
|
|
148
|
-
);
|
|
149
|
-
|
|
150
|
-
// Advance less than interval
|
|
151
|
-
act(() => {
|
|
152
|
-
jest.advanceTimersByTime(1500);
|
|
153
|
-
});
|
|
154
|
-
expect(mockCarouselController.next).not.toHaveBeenCalled();
|
|
155
|
-
|
|
156
|
-
// Advance to complete interval
|
|
157
|
-
act(() => {
|
|
158
|
-
jest.advanceTimersByTime(500);
|
|
159
|
-
});
|
|
160
|
-
expect(mockCarouselController.next).toHaveBeenCalledTimes(1);
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
it("should chain autoplay calls correctly", () => {
|
|
164
|
-
renderHook(() =>
|
|
165
|
-
useAutoPlay({
|
|
166
|
-
autoPlay: true,
|
|
167
|
-
autoPlayInterval: 1000,
|
|
168
|
-
carouselController: mockCarouselController,
|
|
169
|
-
})
|
|
170
|
-
);
|
|
171
|
-
|
|
172
|
-
// First interval
|
|
173
|
-
act(() => {
|
|
174
|
-
jest.runOnlyPendingTimers();
|
|
175
|
-
});
|
|
176
|
-
expect(mockCarouselController.next).toHaveBeenCalledTimes(1);
|
|
177
|
-
|
|
178
|
-
// Trigger onFinished callback to start the next timer
|
|
179
|
-
const onFinished = mockCarouselController.next.mock.calls[0][0].onFinished;
|
|
180
|
-
act(() => {
|
|
181
|
-
onFinished();
|
|
182
|
-
jest.runOnlyPendingTimers();
|
|
183
|
-
});
|
|
184
|
-
expect(mockCarouselController.next).toHaveBeenCalledTimes(2);
|
|
185
|
-
|
|
186
|
-
// Trigger onFinished callback to start the next timer
|
|
187
|
-
const onFinished2 = mockCarouselController.next.mock.calls[1][0].onFinished;
|
|
188
|
-
act(() => {
|
|
189
|
-
onFinished2();
|
|
190
|
-
jest.runOnlyPendingTimers();
|
|
191
|
-
});
|
|
192
|
-
expect(mockCarouselController.next).toHaveBeenCalledTimes(3);
|
|
193
|
-
});
|
|
194
|
-
});
|