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,252 +0,0 @@
|
|
|
1
|
-
import { horizontalStackLayout, useHorizontalStackLayout, verticalStackLayout } from "./stack";
|
|
2
|
-
|
|
3
|
-
// Mock react-native-reanimated
|
|
4
|
-
jest.mock("react-native-reanimated", () => ({
|
|
5
|
-
interpolate: jest.fn((value, inputRange, outputRange) => {
|
|
6
|
-
// Simple linear interpolation mock for testing
|
|
7
|
-
const inputMin = inputRange[0];
|
|
8
|
-
const inputMax = inputRange[inputRange.length - 1];
|
|
9
|
-
const outputMin = outputRange[0];
|
|
10
|
-
const outputMax = outputRange[outputRange.length - 1];
|
|
11
|
-
|
|
12
|
-
if (value <= inputMin) return outputMin;
|
|
13
|
-
if (value >= inputMax) return outputMax;
|
|
14
|
-
|
|
15
|
-
// Linear interpolation
|
|
16
|
-
const progress = (value - inputMin) / (inputMax - inputMin);
|
|
17
|
-
return outputMin + progress * (outputMax - outputMin);
|
|
18
|
-
}),
|
|
19
|
-
Extrapolation: {
|
|
20
|
-
CLAMP: "clamp",
|
|
21
|
-
},
|
|
22
|
-
}));
|
|
23
|
-
|
|
24
|
-
// Mock react
|
|
25
|
-
jest.mock("react", () => ({
|
|
26
|
-
useMemo: jest.fn((fn) => fn()),
|
|
27
|
-
}));
|
|
28
|
-
|
|
29
|
-
// Mock Dimensions
|
|
30
|
-
jest.mock("react-native", () => ({
|
|
31
|
-
Dimensions: {
|
|
32
|
-
get: jest.fn(() => ({ width: 375, height: 812 })),
|
|
33
|
-
},
|
|
34
|
-
}));
|
|
35
|
-
|
|
36
|
-
describe("horizontalStackLayout", () => {
|
|
37
|
-
it("should make the rotateZDeg works properly when it is passed in horizontal-stack mode through modeConfig", () => {
|
|
38
|
-
const screenWidth = 375;
|
|
39
|
-
|
|
40
|
-
const calculator = horizontalStackLayout({
|
|
41
|
-
showLength: 3,
|
|
42
|
-
snapDirection: "left",
|
|
43
|
-
moveSize: screenWidth,
|
|
44
|
-
stackInterval: 18,
|
|
45
|
-
scaleInterval: 0.04,
|
|
46
|
-
opacityInterval: 0.1,
|
|
47
|
-
rotateZDeg: 30,
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
const result1 = calculator(-0.5);
|
|
51
|
-
expect(result1).toHaveProperty("transform");
|
|
52
|
-
expect(result1).toHaveProperty("zIndex");
|
|
53
|
-
expect(result1).toHaveProperty("opacity");
|
|
54
|
-
expect(result1.transform).toHaveLength(3);
|
|
55
|
-
|
|
56
|
-
const result2 = calculator(-1);
|
|
57
|
-
expect(result2).toHaveProperty("transform");
|
|
58
|
-
expect(result2).toHaveProperty("zIndex");
|
|
59
|
-
expect(result2).toHaveProperty("opacity");
|
|
60
|
-
expect(result2.transform).toHaveLength(3);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it("should handle right snap direction", () => {
|
|
64
|
-
const calculator = horizontalStackLayout({
|
|
65
|
-
showLength: 3,
|
|
66
|
-
snapDirection: "right",
|
|
67
|
-
moveSize: 375,
|
|
68
|
-
stackInterval: 18,
|
|
69
|
-
scaleInterval: 0.04,
|
|
70
|
-
opacityInterval: 0.1,
|
|
71
|
-
rotateZDeg: 30,
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
const result = calculator(0);
|
|
75
|
-
expect(result).toHaveProperty("transform");
|
|
76
|
-
expect(result).toHaveProperty("zIndex");
|
|
77
|
-
expect(result).toHaveProperty("opacity");
|
|
78
|
-
expect(result.transform).toHaveLength(3);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it("should handle default config", () => {
|
|
82
|
-
const calculator = horizontalStackLayout();
|
|
83
|
-
const result = calculator(0);
|
|
84
|
-
|
|
85
|
-
expect(result).toHaveProperty("transform");
|
|
86
|
-
expect(result).toHaveProperty("zIndex");
|
|
87
|
-
expect(result).toHaveProperty("opacity");
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it("should handle edge values", () => {
|
|
91
|
-
const calculator = horizontalStackLayout({
|
|
92
|
-
showLength: 5,
|
|
93
|
-
snapDirection: "left",
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
const extremeLeftResult = calculator(-2);
|
|
97
|
-
const extremeRightResult = calculator(4);
|
|
98
|
-
|
|
99
|
-
expect(extremeLeftResult).toHaveProperty("transform");
|
|
100
|
-
expect(extremeRightResult).toHaveProperty("transform");
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
it("should handle custom parameters", () => {
|
|
104
|
-
const calculator = horizontalStackLayout({
|
|
105
|
-
showLength: 4,
|
|
106
|
-
snapDirection: "right",
|
|
107
|
-
moveSize: 400,
|
|
108
|
-
stackInterval: 25,
|
|
109
|
-
scaleInterval: 0.06,
|
|
110
|
-
opacityInterval: 0.15,
|
|
111
|
-
rotateZDeg: 45,
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
const result = calculator(1);
|
|
115
|
-
expect(result).toHaveProperty("transform");
|
|
116
|
-
expect(result.transform).toHaveLength(3);
|
|
117
|
-
expect(result.transform?.[2]).toHaveProperty("rotateZ");
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
describe("verticalStackLayout", () => {
|
|
122
|
-
it("should handle left snap direction", () => {
|
|
123
|
-
const calculator = verticalStackLayout({
|
|
124
|
-
showLength: 3,
|
|
125
|
-
snapDirection: "left",
|
|
126
|
-
moveSize: 375,
|
|
127
|
-
stackInterval: 18,
|
|
128
|
-
scaleInterval: 0.04,
|
|
129
|
-
opacityInterval: 0.1,
|
|
130
|
-
rotateZDeg: 30,
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
const result = calculator(0);
|
|
134
|
-
expect(result).toHaveProperty("transform");
|
|
135
|
-
expect(result).toHaveProperty("zIndex");
|
|
136
|
-
expect(result).toHaveProperty("opacity");
|
|
137
|
-
expect(result.transform).toHaveLength(4); // includesTranslateY
|
|
138
|
-
expect(result.transform?.[3]).toHaveProperty("translateY");
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
it("should handle right snap direction", () => {
|
|
142
|
-
const calculator = verticalStackLayout({
|
|
143
|
-
showLength: 3,
|
|
144
|
-
snapDirection: "right",
|
|
145
|
-
moveSize: 375,
|
|
146
|
-
stackInterval: 18,
|
|
147
|
-
scaleInterval: 0.04,
|
|
148
|
-
opacityInterval: 0.1,
|
|
149
|
-
rotateZDeg: 30,
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
const result = calculator(0);
|
|
153
|
-
expect(result).toHaveProperty("transform");
|
|
154
|
-
expect(result.transform).toHaveLength(4);
|
|
155
|
-
expect(result.transform?.[3]).toHaveProperty("translateY");
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
it("should handle default config", () => {
|
|
159
|
-
const calculator = verticalStackLayout();
|
|
160
|
-
const result = calculator(0);
|
|
161
|
-
|
|
162
|
-
expect(result).toHaveProperty("transform");
|
|
163
|
-
expect(result).toHaveProperty("zIndex");
|
|
164
|
-
expect(result).toHaveProperty("opacity");
|
|
165
|
-
expect(result.transform).toHaveLength(4);
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
it("should handle different values", () => {
|
|
169
|
-
const calculator = verticalStackLayout({
|
|
170
|
-
showLength: 4,
|
|
171
|
-
snapDirection: "left",
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
const leftResult = calculator(-1);
|
|
175
|
-
const centerResult = calculator(0);
|
|
176
|
-
const rightResult = calculator(1);
|
|
177
|
-
|
|
178
|
-
expect(leftResult).toHaveProperty("transform");
|
|
179
|
-
expect(centerResult).toHaveProperty("transform");
|
|
180
|
-
expect(rightResult).toHaveProperty("transform");
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
it("should handle fractional values", () => {
|
|
184
|
-
const calculator = verticalStackLayout({
|
|
185
|
-
showLength: 3,
|
|
186
|
-
snapDirection: "right",
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
const result = calculator(0.5);
|
|
190
|
-
expect(result).toHaveProperty("transform");
|
|
191
|
-
expect(result.transform).toHaveLength(4);
|
|
192
|
-
});
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
describe("useHorizontalStackLayout", () => {
|
|
196
|
-
it("should return layout and config for left snap direction", () => {
|
|
197
|
-
const customAnimationConfig = {
|
|
198
|
-
snapDirection: "left" as const,
|
|
199
|
-
showLength: 3,
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
const result = useHorizontalStackLayout(customAnimationConfig);
|
|
203
|
-
|
|
204
|
-
expect(result).toHaveProperty("layout");
|
|
205
|
-
expect(result).toHaveProperty("config");
|
|
206
|
-
expect(typeof result.layout).toBe("function");
|
|
207
|
-
expect(result.config.type).toBe("positive");
|
|
208
|
-
expect(result.config.viewCount).toBe(3);
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
it("should return layout and config for right snap direction", () => {
|
|
212
|
-
const customAnimationConfig = {
|
|
213
|
-
snapDirection: "right" as const,
|
|
214
|
-
showLength: 4,
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
const result = useHorizontalStackLayout(customAnimationConfig);
|
|
218
|
-
|
|
219
|
-
expect(result).toHaveProperty("layout");
|
|
220
|
-
expect(result).toHaveProperty("config");
|
|
221
|
-
expect(result.config.type).toBe("negative");
|
|
222
|
-
expect(result.config.viewCount).toBe(4);
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
it("should handle default config", () => {
|
|
226
|
-
const result = useHorizontalStackLayout();
|
|
227
|
-
|
|
228
|
-
expect(result).toHaveProperty("layout");
|
|
229
|
-
expect(result).toHaveProperty("config");
|
|
230
|
-
expect(typeof result.layout).toBe("function");
|
|
231
|
-
expect(result.config.type).toBe("positive"); // Default snapDirection is "left"
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
it("should handle empty custom config", () => {
|
|
235
|
-
const result = useHorizontalStackLayout({}, {});
|
|
236
|
-
|
|
237
|
-
expect(result).toHaveProperty("layout");
|
|
238
|
-
expect(result).toHaveProperty("config");
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
it("should merge custom config correctly", () => {
|
|
242
|
-
const customAnimationConfig = {
|
|
243
|
-
snapDirection: "right" as const,
|
|
244
|
-
showLength: 2,
|
|
245
|
-
};
|
|
246
|
-
|
|
247
|
-
const result = useHorizontalStackLayout(customAnimationConfig);
|
|
248
|
-
|
|
249
|
-
expect(result.config.type).toBe("negative");
|
|
250
|
-
expect(result.config.viewCount).toBe(2);
|
|
251
|
-
});
|
|
252
|
-
});
|
package/src/store/index.test.tsx
DELETED
|
@@ -1,314 +0,0 @@
|
|
|
1
|
-
import { act, render } from "@testing-library/react-native";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import { Text } from "react-native";
|
|
4
|
-
|
|
5
|
-
import { ICommonVariables } from "../hooks/useCommonVariables";
|
|
6
|
-
import { GlobalStateContext, GlobalStateProvider, IContext, useGlobalState } from "./index";
|
|
7
|
-
|
|
8
|
-
const createSharedValue = <T,>(initial: T) => ({ value: initial });
|
|
9
|
-
|
|
10
|
-
describe("GlobalStateProvider", () => {
|
|
11
|
-
const mockProps = {
|
|
12
|
-
width: 300,
|
|
13
|
-
height: 200,
|
|
14
|
-
data: [1, 2, 3],
|
|
15
|
-
renderItem: () => <Text>Item</Text>,
|
|
16
|
-
} as any;
|
|
17
|
-
|
|
18
|
-
const mockCommon = {
|
|
19
|
-
size: 300,
|
|
20
|
-
validLength: 3,
|
|
21
|
-
handlerOffset: createSharedValue(0),
|
|
22
|
-
resolvedSize: createSharedValue<number | null>(300),
|
|
23
|
-
sizePhase: createSharedValue("ready" as const),
|
|
24
|
-
} as ICommonVariables;
|
|
25
|
-
|
|
26
|
-
const mockValue: Pick<IContext, "props" | "common"> = {
|
|
27
|
-
props: mockProps,
|
|
28
|
-
common: mockCommon,
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
it("should render children correctly", () => {
|
|
32
|
-
const { getByText } = render(
|
|
33
|
-
<GlobalStateProvider value={mockValue}>
|
|
34
|
-
<Text>Test Child</Text>
|
|
35
|
-
</GlobalStateProvider>
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
expect(getByText("Test Child")).toBeTruthy();
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it("should provide context value with layout methods", () => {
|
|
42
|
-
let contextValue: any;
|
|
43
|
-
|
|
44
|
-
const TestComponent = () => {
|
|
45
|
-
contextValue = React.useContext(GlobalStateContext);
|
|
46
|
-
return <Text>Test</Text>;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
render(
|
|
50
|
-
<GlobalStateProvider value={mockValue}>
|
|
51
|
-
<TestComponent />
|
|
52
|
-
</GlobalStateProvider>
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
expect(contextValue).toHaveProperty("props");
|
|
56
|
-
expect(contextValue).toHaveProperty("common");
|
|
57
|
-
expect(contextValue).toHaveProperty("layout");
|
|
58
|
-
expect(contextValue.layout).toHaveProperty("containerSize");
|
|
59
|
-
expect(contextValue.layout).toHaveProperty("itemDimensions");
|
|
60
|
-
expect(contextValue.layout).toHaveProperty("updateItemDimensions");
|
|
61
|
-
expect(contextValue.layout).toHaveProperty("updateContainerSize");
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it("should initialize containerSize with default values", () => {
|
|
65
|
-
let contextValue: any;
|
|
66
|
-
|
|
67
|
-
const TestComponent = () => {
|
|
68
|
-
contextValue = React.useContext(GlobalStateContext);
|
|
69
|
-
return <Text>Test</Text>;
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
render(
|
|
73
|
-
<GlobalStateProvider value={mockValue}>
|
|
74
|
-
<TestComponent />
|
|
75
|
-
</GlobalStateProvider>
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
expect(contextValue.layout.containerSize.value).toEqual({ width: 0, height: 0 });
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it("should initialize itemDimensions with empty object", () => {
|
|
82
|
-
let contextValue: any;
|
|
83
|
-
|
|
84
|
-
const TestComponent = () => {
|
|
85
|
-
contextValue = React.useContext(GlobalStateContext);
|
|
86
|
-
return <Text>Test</Text>;
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
render(
|
|
90
|
-
<GlobalStateProvider value={mockValue}>
|
|
91
|
-
<TestComponent />
|
|
92
|
-
</GlobalStateProvider>
|
|
93
|
-
);
|
|
94
|
-
|
|
95
|
-
expect(contextValue.layout.itemDimensions.value).toEqual({});
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
it("should provide updateItemDimensions function", () => {
|
|
99
|
-
let contextValue: any;
|
|
100
|
-
|
|
101
|
-
const TestComponent = () => {
|
|
102
|
-
contextValue = React.useContext(GlobalStateContext);
|
|
103
|
-
return <Text>Test</Text>;
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
render(
|
|
107
|
-
<GlobalStateProvider value={mockValue}>
|
|
108
|
-
<TestComponent />
|
|
109
|
-
</GlobalStateProvider>
|
|
110
|
-
);
|
|
111
|
-
|
|
112
|
-
expect(typeof contextValue.layout.updateItemDimensions).toBe("function");
|
|
113
|
-
|
|
114
|
-
act(() => {
|
|
115
|
-
contextValue.layout.updateItemDimensions(0, { width: 100, height: 50 });
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
expect(contextValue.layout.itemDimensions.value).toEqual({
|
|
119
|
-
0: { width: 100, height: 50 },
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
it("should provide updateContainerSize function", () => {
|
|
124
|
-
let contextValue: any;
|
|
125
|
-
|
|
126
|
-
const TestComponent = () => {
|
|
127
|
-
contextValue = React.useContext(GlobalStateContext);
|
|
128
|
-
return <Text>Test</Text>;
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
render(
|
|
132
|
-
<GlobalStateProvider value={mockValue}>
|
|
133
|
-
<TestComponent />
|
|
134
|
-
</GlobalStateProvider>
|
|
135
|
-
);
|
|
136
|
-
|
|
137
|
-
expect(typeof contextValue.layout.updateContainerSize).toBe("function");
|
|
138
|
-
|
|
139
|
-
act(() => {
|
|
140
|
-
contextValue.layout.updateContainerSize({ width: 400, height: 300 });
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
expect(contextValue.layout.containerSize.value).toEqual({ width: 400, height: 300 });
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
it("should merge props and common with layout", () => {
|
|
147
|
-
let contextValue: any;
|
|
148
|
-
|
|
149
|
-
const TestComponent = () => {
|
|
150
|
-
contextValue = React.useContext(GlobalStateContext);
|
|
151
|
-
return <Text>Test</Text>;
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
render(
|
|
155
|
-
<GlobalStateProvider value={mockValue}>
|
|
156
|
-
<TestComponent />
|
|
157
|
-
</GlobalStateProvider>
|
|
158
|
-
);
|
|
159
|
-
|
|
160
|
-
expect(contextValue.props).toEqual(mockProps);
|
|
161
|
-
expect(contextValue.common).toEqual(mockCommon);
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
it("should handle multiple children", () => {
|
|
165
|
-
const { getByText } = render(
|
|
166
|
-
<GlobalStateProvider value={mockValue}>
|
|
167
|
-
<Text>First Child</Text>
|
|
168
|
-
<Text>Second Child</Text>
|
|
169
|
-
</GlobalStateProvider>
|
|
170
|
-
);
|
|
171
|
-
|
|
172
|
-
expect(getByText("First Child")).toBeTruthy();
|
|
173
|
-
expect(getByText("Second Child")).toBeTruthy();
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
it("should handle updateItemDimensions with multiple items", () => {
|
|
177
|
-
let contextValue: any;
|
|
178
|
-
|
|
179
|
-
const TestComponent = () => {
|
|
180
|
-
contextValue = React.useContext(GlobalStateContext);
|
|
181
|
-
return <Text>Test</Text>;
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
render(
|
|
185
|
-
<GlobalStateProvider value={mockValue}>
|
|
186
|
-
<TestComponent />
|
|
187
|
-
</GlobalStateProvider>
|
|
188
|
-
);
|
|
189
|
-
|
|
190
|
-
act(() => {
|
|
191
|
-
contextValue.layout.updateItemDimensions(0, { width: 100, height: 50 });
|
|
192
|
-
contextValue.layout.updateItemDimensions(1, { width: 120, height: 60 });
|
|
193
|
-
contextValue.layout.updateItemDimensions(2, { width: 90, height: 45 });
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
expect(contextValue.layout.itemDimensions.value).toEqual({
|
|
197
|
-
0: { width: 100, height: 50 },
|
|
198
|
-
1: { width: 120, height: 60 },
|
|
199
|
-
2: { width: 90, height: 45 },
|
|
200
|
-
});
|
|
201
|
-
});
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
describe("useGlobalState", () => {
|
|
205
|
-
const mockValue: Pick<IContext, "props" | "common"> = {
|
|
206
|
-
props: { width: 300, data: [1, 2, 3], renderItem: () => <Text>Item</Text> } as any,
|
|
207
|
-
common: {
|
|
208
|
-
size: 300,
|
|
209
|
-
validLength: 3,
|
|
210
|
-
handlerOffset: createSharedValue(0),
|
|
211
|
-
resolvedSize: createSharedValue<number | null>(300),
|
|
212
|
-
sizePhase: createSharedValue("ready" as const),
|
|
213
|
-
} as ICommonVariables,
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
it("should return context value when used within provider", () => {
|
|
217
|
-
let hookResult: any;
|
|
218
|
-
|
|
219
|
-
const TestComponent = () => {
|
|
220
|
-
hookResult = useGlobalState();
|
|
221
|
-
return <Text>Test</Text>;
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
render(
|
|
225
|
-
<GlobalStateProvider value={mockValue}>
|
|
226
|
-
<TestComponent />
|
|
227
|
-
</GlobalStateProvider>
|
|
228
|
-
);
|
|
229
|
-
|
|
230
|
-
expect(hookResult).toHaveProperty("props");
|
|
231
|
-
expect(hookResult).toHaveProperty("common");
|
|
232
|
-
expect(hookResult).toHaveProperty("layout");
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
it("should provide expected hook functionality", () => {
|
|
236
|
-
let hookResult: any;
|
|
237
|
-
|
|
238
|
-
const TestComponent = () => {
|
|
239
|
-
hookResult = useGlobalState();
|
|
240
|
-
return <Text>Test</Text>;
|
|
241
|
-
};
|
|
242
|
-
|
|
243
|
-
const mockValue: Pick<IContext, "props" | "common"> = {
|
|
244
|
-
props: { width: 300, data: [1, 2, 3], renderItem: () => <Text>Item</Text> } as any,
|
|
245
|
-
common: { size: 300, validLength: 3 } as ICommonVariables,
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
render(
|
|
249
|
-
<GlobalStateProvider value={mockValue}>
|
|
250
|
-
<TestComponent />
|
|
251
|
-
</GlobalStateProvider>
|
|
252
|
-
);
|
|
253
|
-
|
|
254
|
-
expect(hookResult).toHaveProperty("props");
|
|
255
|
-
expect(hookResult).toHaveProperty("common");
|
|
256
|
-
expect(hookResult).toHaveProperty("layout");
|
|
257
|
-
});
|
|
258
|
-
|
|
259
|
-
it("should return the same context value as directly accessing context", () => {
|
|
260
|
-
let hookResult: any;
|
|
261
|
-
let contextResult: any;
|
|
262
|
-
|
|
263
|
-
const TestComponent = () => {
|
|
264
|
-
hookResult = useGlobalState();
|
|
265
|
-
contextResult = React.useContext(GlobalStateContext);
|
|
266
|
-
return <Text>Test</Text>;
|
|
267
|
-
};
|
|
268
|
-
|
|
269
|
-
render(
|
|
270
|
-
<GlobalStateProvider value={mockValue}>
|
|
271
|
-
<TestComponent />
|
|
272
|
-
</GlobalStateProvider>
|
|
273
|
-
);
|
|
274
|
-
|
|
275
|
-
expect(hookResult).toBe(contextResult);
|
|
276
|
-
});
|
|
277
|
-
|
|
278
|
-
it("should provide all expected properties", () => {
|
|
279
|
-
let hookResult: any;
|
|
280
|
-
|
|
281
|
-
const TestComponent = () => {
|
|
282
|
-
hookResult = useGlobalState();
|
|
283
|
-
return <Text>Test</Text>;
|
|
284
|
-
};
|
|
285
|
-
|
|
286
|
-
render(
|
|
287
|
-
<GlobalStateProvider value={mockValue}>
|
|
288
|
-
<TestComponent />
|
|
289
|
-
</GlobalStateProvider>
|
|
290
|
-
);
|
|
291
|
-
|
|
292
|
-
expect(hookResult.props).toEqual(mockValue.props);
|
|
293
|
-
expect(hookResult.common).toEqual(mockValue.common);
|
|
294
|
-
expect(hookResult.layout).toHaveProperty("containerSize");
|
|
295
|
-
expect(hookResult.layout).toHaveProperty("itemDimensions");
|
|
296
|
-
expect(hookResult.layout).toHaveProperty("updateItemDimensions");
|
|
297
|
-
expect(hookResult.layout).toHaveProperty("updateContainerSize");
|
|
298
|
-
});
|
|
299
|
-
});
|
|
300
|
-
|
|
301
|
-
describe("GlobalStateContext", () => {
|
|
302
|
-
it("should have default empty context value", () => {
|
|
303
|
-
let contextValue: any;
|
|
304
|
-
|
|
305
|
-
const TestComponent = () => {
|
|
306
|
-
contextValue = React.useContext(GlobalStateContext);
|
|
307
|
-
return <Text>Test</Text>;
|
|
308
|
-
};
|
|
309
|
-
|
|
310
|
-
render(<TestComponent />);
|
|
311
|
-
|
|
312
|
-
expect(contextValue).toEqual({});
|
|
313
|
-
});
|
|
314
|
-
});
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { computeGestureTranslation } from "./compute-gesture-translation";
|
|
2
|
-
|
|
3
|
-
describe("computeGestureTranslation", () => {
|
|
4
|
-
it("should clamp right overdrag when overscrollEnabled is false", () => {
|
|
5
|
-
const next = computeGestureTranslation({
|
|
6
|
-
loop: false,
|
|
7
|
-
overscrollEnabled: false,
|
|
8
|
-
currentTranslation: 0,
|
|
9
|
-
panOffset: 0,
|
|
10
|
-
panTranslation: 120,
|
|
11
|
-
max: 500,
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
expect(next).toBe(0);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it("should keep damping behavior when overscrollEnabled is true and dragging past start", () => {
|
|
18
|
-
const next = computeGestureTranslation({
|
|
19
|
-
loop: false,
|
|
20
|
-
overscrollEnabled: true,
|
|
21
|
-
currentTranslation: 20,
|
|
22
|
-
panOffset: 0,
|
|
23
|
-
panTranslation: 120,
|
|
24
|
-
max: 500,
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
expect(next).toBe(60);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it("should apply damping when overscrollEnabled is true and dragging past end", () => {
|
|
31
|
-
const next = computeGestureTranslation({
|
|
32
|
-
loop: false,
|
|
33
|
-
overscrollEnabled: true,
|
|
34
|
-
currentTranslation: -600,
|
|
35
|
-
panOffset: -500,
|
|
36
|
-
panTranslation: -100,
|
|
37
|
-
max: 500,
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
// boundary = -max = -500, fixed = -500 - (-500) = 0, dynamic = -100 - 0 = -100
|
|
41
|
-
// result = -500 + (-100 * 0.5) = -550
|
|
42
|
-
expect(next).toBe(-550);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it("should pass through raw value in loop mode", () => {
|
|
46
|
-
const next = computeGestureTranslation({
|
|
47
|
-
loop: true,
|
|
48
|
-
overscrollEnabled: false,
|
|
49
|
-
currentTranslation: 0,
|
|
50
|
-
panOffset: 0,
|
|
51
|
-
panTranslation: 300,
|
|
52
|
-
max: 500,
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
expect(next).toBe(300);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("should return raw value when within bounds and not looping", () => {
|
|
59
|
-
const next = computeGestureTranslation({
|
|
60
|
-
loop: false,
|
|
61
|
-
overscrollEnabled: true,
|
|
62
|
-
currentTranslation: -200,
|
|
63
|
-
panOffset: -100,
|
|
64
|
-
panTranslation: -50,
|
|
65
|
-
max: 500,
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
expect(next).toBe(-150);
|
|
69
|
-
});
|
|
70
|
-
});
|