react-native-reanimated-carousel 5.0.0-beta.7 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +60 -28
- package/lib/commonjs/components/Carousel.js +1 -1
- package/lib/commonjs/components/Carousel.js.map +1 -1
- package/lib/commonjs/components/CarouselLayout.js +1 -1
- package/lib/commonjs/components/CarouselLayout.js.map +1 -1
- package/lib/commonjs/components/ItemLayout.js +1 -1
- package/lib/commonjs/components/ItemLayout.js.map +1 -1
- package/lib/commonjs/components/ItemRenderer.js +1 -1
- package/lib/commonjs/components/ItemRenderer.js.map +1 -1
- package/lib/commonjs/components/Pagination/PaginationItem.js +2 -0
- package/lib/commonjs/components/Pagination/PaginationItem.js.map +1 -0
- package/lib/commonjs/components/Pagination/index.js +1 -1
- package/lib/commonjs/components/Pagination/index.js.map +1 -1
- package/lib/commonjs/components/ScrollViewGesture.js +1 -1
- package/lib/commonjs/components/ScrollViewGesture.js.map +1 -1
- package/lib/commonjs/hooks/useAutoPlay.js +1 -1
- package/lib/commonjs/hooks/useAutoPlay.js.map +1 -1
- package/lib/commonjs/hooks/useCarouselController.js +1 -1
- package/lib/commonjs/hooks/useCarouselController.js.map +1 -1
- package/lib/commonjs/hooks/useCommonVariables.js +1 -1
- package/lib/commonjs/hooks/useCommonVariables.js.map +1 -1
- package/lib/commonjs/hooks/useInitProps.js +1 -1
- package/lib/commonjs/hooks/useInitProps.js.map +1 -1
- package/lib/commonjs/hooks/useLayoutConfig.js +1 -1
- package/lib/commonjs/hooks/useLayoutConfig.js.map +1 -1
- package/lib/commonjs/hooks/useOffsetX.js.map +1 -1
- package/lib/commonjs/hooks/useOnProgressChange.js +1 -1
- package/lib/commonjs/hooks/useOnProgressChange.js.map +1 -1
- package/lib/commonjs/hooks/usePanGestureProxy.js.map +1 -1
- package/lib/commonjs/hooks/usePropsErrorBoundary.js +1 -1
- package/lib/commonjs/hooks/usePropsErrorBoundary.js.map +1 -1
- package/lib/commonjs/hooks/useUpdateGestureConfig.js.map +1 -1
- package/lib/commonjs/hooks/useVisibleRanges.js.map +1 -1
- package/lib/commonjs/index.js +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/layouts/index.js.map +1 -1
- package/lib/commonjs/layouts/normal.js +1 -1
- package/lib/commonjs/layouts/normal.js.map +1 -1
- package/lib/commonjs/layouts/parallax.js +1 -1
- package/lib/commonjs/layouts/parallax.js.map +1 -1
- package/lib/commonjs/layouts/stack.js +1 -1
- package/lib/commonjs/layouts/stack.js.map +1 -1
- package/lib/commonjs/public-types.js +2 -0
- package/lib/commonjs/public-types.js.map +1 -0
- package/lib/commonjs/store/index.js.map +1 -1
- package/lib/commonjs/utils/carousel-direction.js +2 -0
- package/lib/commonjs/utils/carousel-direction.js.map +1 -0
- package/lib/commonjs/utils/carousel-math.js +2 -0
- package/lib/commonjs/utils/carousel-math.js.map +1 -0
- package/lib/commonjs/utils/deal-with-animation.js +1 -1
- package/lib/commonjs/utils/deal-with-animation.js.map +1 -1
- package/lib/module/components/Carousel.js +1 -1
- package/lib/module/components/Carousel.js.map +1 -1
- package/lib/module/components/CarouselLayout.js +1 -1
- package/lib/module/components/CarouselLayout.js.map +1 -1
- package/lib/module/components/ItemLayout.js +1 -1
- package/lib/module/components/ItemLayout.js.map +1 -1
- package/lib/module/components/ItemRenderer.js +1 -1
- package/lib/module/components/ItemRenderer.js.map +1 -1
- package/lib/module/components/LazyView.js +1 -1
- package/lib/module/components/LazyView.js.map +1 -1
- package/lib/module/components/Pagination/PaginationItem.js +2 -0
- package/lib/module/components/Pagination/PaginationItem.js.map +1 -0
- package/lib/module/components/Pagination/index.js +1 -1
- package/lib/module/components/Pagination/index.js.map +1 -1
- package/lib/module/components/ScrollViewGesture.js +1 -1
- package/lib/module/components/ScrollViewGesture.js.map +1 -1
- package/lib/module/constants/index.js +1 -1
- package/lib/module/constants/index.js.map +1 -1
- package/lib/module/hooks/useAutoPlay.js +1 -1
- package/lib/module/hooks/useAutoPlay.js.map +1 -1
- package/lib/module/hooks/useCarouselController.js +1 -1
- package/lib/module/hooks/useCarouselController.js.map +1 -1
- package/lib/module/hooks/useCheckMounted.js +1 -1
- package/lib/module/hooks/useCheckMounted.js.map +1 -1
- package/lib/module/hooks/useCommonVariables.js +1 -1
- package/lib/module/hooks/useCommonVariables.js.map +1 -1
- package/lib/module/hooks/useInitProps.js +1 -1
- package/lib/module/hooks/useInitProps.js.map +1 -1
- package/lib/module/hooks/useLayoutConfig.js +1 -1
- package/lib/module/hooks/useLayoutConfig.js.map +1 -1
- package/lib/module/hooks/useOffsetX.js +1 -1
- package/lib/module/hooks/useOffsetX.js.map +1 -1
- package/lib/module/hooks/useOnProgressChange.js +1 -1
- package/lib/module/hooks/useOnProgressChange.js.map +1 -1
- package/lib/module/hooks/usePanGestureProxy.js +1 -1
- package/lib/module/hooks/usePanGestureProxy.js.map +1 -1
- package/lib/module/hooks/usePropsErrorBoundary.js +1 -1
- package/lib/module/hooks/usePropsErrorBoundary.js.map +1 -1
- package/lib/module/hooks/useUpdateGestureConfig.js +1 -1
- package/lib/module/hooks/useUpdateGestureConfig.js.map +1 -1
- package/lib/module/hooks/useVisibleRanges.js +1 -1
- package/lib/module/hooks/useVisibleRanges.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/layouts/index.js +1 -1
- package/lib/module/layouts/index.js.map +1 -1
- package/lib/module/layouts/normal.js +1 -1
- package/lib/module/layouts/normal.js.map +1 -1
- package/lib/module/layouts/parallax.js +1 -1
- package/lib/module/layouts/parallax.js.map +1 -1
- package/lib/module/layouts/stack.js +1 -1
- package/lib/module/layouts/stack.js.map +1 -1
- package/lib/module/package.json +1 -0
- package/lib/module/public-types.js +2 -0
- package/lib/module/public-types.js.map +1 -0
- package/lib/module/store/index.js +1 -1
- package/lib/module/store/index.js.map +1 -1
- package/lib/module/types.js +1 -1
- package/lib/module/utils/carousel-direction.js +2 -0
- package/lib/module/utils/carousel-direction.js.map +1 -0
- package/lib/module/utils/carousel-math.js +2 -0
- package/lib/module/utils/carousel-math.js.map +1 -0
- package/lib/module/utils/compute-gesture-translation.js +1 -1
- package/lib/module/utils/compute-gesture-translation.js.map +1 -1
- package/lib/module/utils/compute-offset-if-size-changed.js +1 -1
- package/lib/module/utils/compute-offset-if-size-changed.js.map +1 -1
- package/lib/module/utils/computed-with-auto-fill-data.js +1 -1
- package/lib/module/utils/computed-with-auto-fill-data.js.map +1 -1
- package/lib/module/utils/deal-with-animation.js +1 -1
- package/lib/module/utils/deal-with-animation.js.map +1 -1
- package/lib/module/utils/log.js +1 -1
- package/lib/module/utils/log.js.map +1 -1
- package/lib/module/utils/sanitize-animation-style.js +1 -1
- package/lib/module/utils/sanitize-animation-style.js.map +1 -1
- package/lib/typescript/commonjs/components/Carousel.d.ts +8 -0
- package/lib/typescript/commonjs/components/Carousel.d.ts.map +1 -0
- package/lib/typescript/{components → commonjs/components}/CarouselLayout.d.ts +5 -8
- package/lib/typescript/commonjs/components/CarouselLayout.d.ts.map +1 -0
- package/lib/typescript/{components → commonjs/components}/ItemLayout.d.ts +7 -6
- package/lib/typescript/commonjs/components/ItemLayout.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/ItemRenderer.d.ts +24 -0
- package/lib/typescript/commonjs/components/ItemRenderer.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/LazyView.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/Pagination/PaginationItem.d.ts +14 -0
- package/lib/typescript/commonjs/components/Pagination/PaginationItem.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/Pagination/index.d.ts +4 -0
- package/lib/typescript/commonjs/components/Pagination/index.d.ts.map +1 -0
- package/lib/typescript/{components → commonjs/components}/ScrollViewGesture.d.ts +3 -4
- package/lib/typescript/commonjs/components/ScrollViewGesture.d.ts.map +1 -0
- package/lib/typescript/commonjs/constants/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks/useAutoPlay.d.ts +12 -0
- package/lib/typescript/commonjs/hooks/useAutoPlay.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks/useCarouselController.d.ts +29 -0
- package/lib/typescript/commonjs/hooks/useCarouselController.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks/useCheckMounted.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks/useCommonVariables.d.ts +18 -0
- package/lib/typescript/commonjs/hooks/useCommonVariables.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks/useInitProps.d.ts +25 -0
- package/lib/typescript/commonjs/hooks/useInitProps.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks/useLayoutConfig.d.ts +8 -0
- package/lib/typescript/commonjs/hooks/useLayoutConfig.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks/useOffsetX.d.ts +13 -0
- package/lib/typescript/commonjs/hooks/useOffsetX.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks/useOnProgressChange.d.ts +12 -0
- package/lib/typescript/commonjs/hooks/useOnProgressChange.d.ts.map +1 -0
- package/lib/typescript/{hooks → commonjs/hooks}/usePanGestureProxy.d.ts +3 -2
- package/lib/typescript/commonjs/hooks/usePanGestureProxy.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks/usePropsErrorBoundary.d.ts +3 -0
- package/lib/typescript/commonjs/hooks/usePropsErrorBoundary.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks/useUpdateGestureConfig.d.ts +9 -0
- package/lib/typescript/commonjs/hooks/useUpdateGestureConfig.d.ts.map +1 -0
- package/lib/typescript/{hooks → commonjs/hooks}/useVisibleRanges.d.ts +2 -2
- package/lib/typescript/commonjs/hooks/useVisibleRanges.d.ts.map +1 -0
- package/lib/typescript/commonjs/index.d.ts +4 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -0
- package/lib/typescript/{layouts → commonjs/layouts}/index.d.ts +0 -1
- package/lib/typescript/commonjs/layouts/index.d.ts.map +1 -0
- package/lib/typescript/{layouts → commonjs/layouts}/normal.d.ts +3 -1
- package/lib/typescript/commonjs/layouts/normal.d.ts.map +1 -0
- package/lib/typescript/commonjs/layouts/parallax.d.ts +27 -0
- package/lib/typescript/commonjs/layouts/parallax.d.ts.map +1 -0
- package/lib/typescript/commonjs/layouts/stack.d.ts +10 -0
- package/lib/typescript/commonjs/layouts/stack.d.ts.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/public-types.d.ts +161 -0
- package/lib/typescript/commonjs/public-types.d.ts.map +1 -0
- package/lib/typescript/{store → commonjs/store}/index.d.ts +8 -8
- package/lib/typescript/commonjs/store/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/types.d.ts +15 -0
- package/lib/typescript/commonjs/types.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils/carousel-direction.d.ts +9 -0
- package/lib/typescript/commonjs/utils/carousel-direction.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils/carousel-math.d.ts +28 -0
- package/lib/typescript/commonjs/utils/carousel-math.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils/compute-gesture-translation.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils/compute-offset-if-size-changed.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils/computed-with-auto-fill-data.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils/deal-with-animation.d.ts +3 -0
- package/lib/typescript/commonjs/utils/deal-with-animation.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils/log.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils/sanitize-animation-style.d.ts.map +1 -0
- package/lib/typescript/module/components/Carousel.d.ts +8 -0
- package/lib/typescript/module/components/Carousel.d.ts.map +1 -0
- package/lib/typescript/module/components/CarouselLayout.d.ts +14 -0
- package/lib/typescript/module/components/CarouselLayout.d.ts.map +1 -0
- package/lib/typescript/module/components/ItemLayout.d.ts +21 -0
- package/lib/typescript/module/components/ItemLayout.d.ts.map +1 -0
- package/lib/typescript/module/components/ItemRenderer.d.ts +24 -0
- package/lib/typescript/module/components/ItemRenderer.d.ts.map +1 -0
- package/lib/typescript/module/components/LazyView.d.ts +8 -0
- package/lib/typescript/module/components/LazyView.d.ts.map +1 -0
- package/lib/typescript/module/components/Pagination/PaginationItem.d.ts +14 -0
- package/lib/typescript/module/components/Pagination/PaginationItem.d.ts.map +1 -0
- package/lib/typescript/module/components/Pagination/index.d.ts +4 -0
- package/lib/typescript/module/components/Pagination/index.d.ts.map +1 -0
- package/lib/typescript/module/components/ScrollViewGesture.d.ts +18 -0
- package/lib/typescript/module/components/ScrollViewGesture.d.ts.map +1 -0
- package/lib/typescript/module/constants/index.d.ts +9 -0
- package/lib/typescript/module/constants/index.d.ts.map +1 -0
- package/lib/typescript/module/hooks/useAutoPlay.d.ts +12 -0
- package/lib/typescript/module/hooks/useAutoPlay.d.ts.map +1 -0
- package/lib/typescript/module/hooks/useCarouselController.d.ts +29 -0
- package/lib/typescript/module/hooks/useCarouselController.d.ts.map +1 -0
- package/lib/typescript/module/hooks/useCheckMounted.d.ts +3 -0
- package/lib/typescript/module/hooks/useCheckMounted.d.ts.map +1 -0
- package/lib/typescript/module/hooks/useCommonVariables.d.ts +18 -0
- package/lib/typescript/module/hooks/useCommonVariables.d.ts.map +1 -0
- package/lib/typescript/module/hooks/useInitProps.d.ts +25 -0
- package/lib/typescript/module/hooks/useInitProps.d.ts.map +1 -0
- package/lib/typescript/module/hooks/useLayoutConfig.d.ts +8 -0
- package/lib/typescript/module/hooks/useLayoutConfig.d.ts.map +1 -0
- package/lib/typescript/module/hooks/useOffsetX.d.ts +13 -0
- package/lib/typescript/module/hooks/useOffsetX.d.ts.map +1 -0
- package/lib/typescript/module/hooks/useOnProgressChange.d.ts +12 -0
- package/lib/typescript/module/hooks/useOnProgressChange.d.ts.map +1 -0
- package/lib/typescript/module/hooks/usePanGestureProxy.d.ts +11 -0
- package/lib/typescript/module/hooks/usePanGestureProxy.d.ts.map +1 -0
- package/lib/typescript/module/hooks/usePropsErrorBoundary.d.ts +3 -0
- package/lib/typescript/module/hooks/usePropsErrorBoundary.d.ts.map +1 -0
- package/lib/typescript/module/hooks/useUpdateGestureConfig.d.ts +9 -0
- package/lib/typescript/module/hooks/useUpdateGestureConfig.d.ts.map +1 -0
- package/lib/typescript/module/hooks/useVisibleRanges.d.ts +22 -0
- package/lib/typescript/module/hooks/useVisibleRanges.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +4 -0
- package/lib/typescript/module/index.d.ts.map +1 -0
- package/lib/typescript/module/layouts/index.d.ts +10 -0
- package/lib/typescript/module/layouts/index.d.ts.map +1 -0
- package/lib/typescript/module/layouts/normal.d.ts +15 -0
- package/lib/typescript/module/layouts/normal.d.ts.map +1 -0
- package/lib/typescript/module/layouts/parallax.d.ts +27 -0
- package/lib/typescript/module/layouts/parallax.d.ts.map +1 -0
- package/lib/typescript/module/layouts/stack.d.ts +10 -0
- package/lib/typescript/module/layouts/stack.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/public-types.d.ts +161 -0
- package/lib/typescript/module/public-types.d.ts.map +1 -0
- package/lib/typescript/module/store/index.d.ts +35 -0
- package/lib/typescript/module/store/index.d.ts.map +1 -0
- package/lib/typescript/module/types.d.ts +15 -0
- package/lib/typescript/module/types.d.ts.map +1 -0
- package/lib/typescript/module/utils/carousel-direction.d.ts +9 -0
- package/lib/typescript/module/utils/carousel-direction.d.ts.map +1 -0
- package/lib/typescript/module/utils/carousel-math.d.ts +28 -0
- package/lib/typescript/module/utils/carousel-math.d.ts.map +1 -0
- package/lib/typescript/module/utils/compute-gesture-translation.d.ts +9 -0
- package/lib/typescript/module/utils/compute-gesture-translation.d.ts.map +1 -0
- package/lib/typescript/module/utils/compute-offset-if-size-changed.d.ts +6 -0
- package/lib/typescript/module/utils/compute-offset-if-size-changed.d.ts.map +1 -0
- package/lib/typescript/module/utils/computed-with-auto-fill-data.d.ts +23 -0
- package/lib/typescript/module/utils/computed-with-auto-fill-data.d.ts.map +1 -0
- package/lib/typescript/module/utils/deal-with-animation.d.ts +3 -0
- package/lib/typescript/module/utils/deal-with-animation.d.ts.map +1 -0
- package/lib/typescript/module/utils/log.d.ts +7 -0
- package/lib/typescript/module/utils/log.d.ts.map +1 -0
- package/lib/typescript/module/utils/sanitize-animation-style.d.ts +3 -0
- package/lib/typescript/module/utils/sanitize-animation-style.d.ts.map +1 -0
- package/package.json +34 -7
- package/scripts/codemods/v5.mjs +502 -0
- package/src/components/Carousel.tsx +5 -5
- package/src/components/CarouselLayout.tsx +53 -91
- package/src/components/ItemLayout.tsx +55 -46
- package/src/components/ItemRenderer.tsx +29 -18
- package/src/components/Pagination/PaginationItem.tsx +162 -0
- package/src/components/Pagination/index.tsx +105 -6
- package/src/components/ScrollViewGesture.tsx +92 -177
- package/src/hooks/useAutoPlay.ts +23 -18
- package/src/hooks/useCarouselController.tsx +194 -340
- package/src/hooks/useCommonVariables.ts +159 -71
- package/src/hooks/useInitProps.ts +161 -71
- package/src/hooks/useLayoutConfig.ts +21 -12
- package/src/hooks/useOffsetX.ts +3 -3
- package/src/hooks/useOnProgressChange.ts +23 -48
- package/src/hooks/usePanGestureProxy.ts +2 -2
- package/src/hooks/usePropsErrorBoundary.ts +32 -90
- package/src/hooks/useUpdateGestureConfig.ts +5 -2
- package/src/hooks/useVisibleRanges.tsx +2 -2
- package/src/index.tsx +14 -9
- package/src/layouts/index.tsx +0 -2
- package/src/layouts/normal.ts +14 -4
- package/src/layouts/parallax.ts +32 -59
- package/src/layouts/stack.ts +30 -70
- package/src/public-types.ts +198 -0
- package/src/store/index.tsx +7 -7
- package/src/types.ts +30 -322
- package/src/utils/carousel-direction.ts +39 -0
- package/src/utils/carousel-math.ts +156 -0
- package/src/utils/deal-with-animation.ts +11 -9
- package/lib/commonjs/components/Pagination/Basic/PaginationItem.js +0 -2
- package/lib/commonjs/components/Pagination/Basic/PaginationItem.js.map +0 -1
- package/lib/commonjs/components/Pagination/Basic/index.js +0 -2
- package/lib/commonjs/components/Pagination/Basic/index.js.map +0 -1
- package/lib/commonjs/components/Pagination/Custom/PaginationItem.js +0 -2
- package/lib/commonjs/components/Pagination/Custom/PaginationItem.js.map +0 -1
- package/lib/commonjs/components/Pagination/Custom/index.js +0 -2
- package/lib/commonjs/components/Pagination/Custom/index.js.map +0 -1
- package/lib/commonjs/utils/compute-offset-if-data-changed.js +0 -2
- package/lib/commonjs/utils/compute-offset-if-data-changed.js.map +0 -1
- package/lib/commonjs/utils/handleroffset-direction.js +0 -2
- package/lib/commonjs/utils/handleroffset-direction.js.map +0 -1
- package/lib/module/components/Pagination/Basic/PaginationItem.js +0 -2
- package/lib/module/components/Pagination/Basic/PaginationItem.js.map +0 -1
- package/lib/module/components/Pagination/Basic/index.js +0 -2
- package/lib/module/components/Pagination/Basic/index.js.map +0 -1
- package/lib/module/components/Pagination/Custom/PaginationItem.js +0 -2
- package/lib/module/components/Pagination/Custom/PaginationItem.js.map +0 -1
- package/lib/module/components/Pagination/Custom/index.js +0 -2
- package/lib/module/components/Pagination/Custom/index.js.map +0 -1
- package/lib/module/utils/compute-offset-if-data-changed.js +0 -2
- package/lib/module/utils/compute-offset-if-data-changed.js.map +0 -1
- package/lib/module/utils/handleroffset-direction.js +0 -2
- package/lib/module/utils/handleroffset-direction.js.map +0 -1
- package/lib/typescript/components/Carousel.d.ts +0 -8
- package/lib/typescript/components/Carousel.d.ts.map +0 -1
- package/lib/typescript/components/CarouselLayout.d.ts.map +0 -1
- package/lib/typescript/components/ItemLayout.d.ts.map +0 -1
- package/lib/typescript/components/ItemRenderer.d.ts +0 -23
- package/lib/typescript/components/ItemRenderer.d.ts.map +0 -1
- package/lib/typescript/components/LazyView.d.ts.map +0 -1
- package/lib/typescript/components/Pagination/Basic/PaginationItem.d.ts +0 -29
- package/lib/typescript/components/Pagination/Basic/PaginationItem.d.ts.map +0 -1
- package/lib/typescript/components/Pagination/Basic/index.d.ts +0 -23
- package/lib/typescript/components/Pagination/Basic/index.d.ts.map +0 -1
- package/lib/typescript/components/Pagination/Custom/PaginationItem.d.ts +0 -35
- package/lib/typescript/components/Pagination/Custom/PaginationItem.d.ts.map +0 -1
- package/lib/typescript/components/Pagination/Custom/index.d.ts +0 -26
- package/lib/typescript/components/Pagination/Custom/index.d.ts.map +0 -1
- package/lib/typescript/components/Pagination/index.d.ts +0 -5
- package/lib/typescript/components/Pagination/index.d.ts.map +0 -1
- package/lib/typescript/components/ScrollViewGesture.d.ts.map +0 -1
- package/lib/typescript/constants/index.d.ts.map +0 -1
- package/lib/typescript/hooks/useAutoPlay.d.ts +0 -12
- package/lib/typescript/hooks/useAutoPlay.d.ts.map +0 -1
- package/lib/typescript/hooks/useCarouselController.d.ts +0 -28
- package/lib/typescript/hooks/useCarouselController.d.ts.map +0 -1
- package/lib/typescript/hooks/useCheckMounted.d.ts.map +0 -1
- package/lib/typescript/hooks/useCommonVariables.d.ts +0 -13
- package/lib/typescript/hooks/useCommonVariables.d.ts.map +0 -1
- package/lib/typescript/hooks/useInitProps.d.ts +0 -10
- package/lib/typescript/hooks/useInitProps.d.ts.map +0 -1
- package/lib/typescript/hooks/useLayoutConfig.d.ts +0 -8
- package/lib/typescript/hooks/useLayoutConfig.d.ts.map +0 -1
- package/lib/typescript/hooks/useOffsetX.d.ts +0 -13
- package/lib/typescript/hooks/useOffsetX.d.ts.map +0 -1
- package/lib/typescript/hooks/useOnProgressChange.d.ts +0 -11
- package/lib/typescript/hooks/useOnProgressChange.d.ts.map +0 -1
- package/lib/typescript/hooks/usePanGestureProxy.d.ts.map +0 -1
- package/lib/typescript/hooks/usePropsErrorBoundary.d.ts +0 -5
- package/lib/typescript/hooks/usePropsErrorBoundary.d.ts.map +0 -1
- package/lib/typescript/hooks/useUpdateGestureConfig.d.ts +0 -6
- package/lib/typescript/hooks/useUpdateGestureConfig.d.ts.map +0 -1
- package/lib/typescript/hooks/useVisibleRanges.d.ts.map +0 -1
- package/lib/typescript/index.d.ts +0 -7
- package/lib/typescript/index.d.ts.map +0 -1
- package/lib/typescript/layouts/index.d.ts.map +0 -1
- package/lib/typescript/layouts/normal.d.ts.map +0 -1
- package/lib/typescript/layouts/parallax.d.ts +0 -47
- package/lib/typescript/layouts/parallax.d.ts.map +0 -1
- package/lib/typescript/layouts/stack.d.ts +0 -38
- package/lib/typescript/layouts/stack.d.ts.map +0 -1
- package/lib/typescript/store/index.d.ts.map +0 -1
- package/lib/typescript/types.d.ts +0 -302
- package/lib/typescript/types.d.ts.map +0 -1
- package/lib/typescript/utils/compute-gesture-translation.d.ts.map +0 -1
- package/lib/typescript/utils/compute-offset-if-data-changed.d.ts +0 -9
- package/lib/typescript/utils/compute-offset-if-data-changed.d.ts.map +0 -1
- package/lib/typescript/utils/compute-offset-if-size-changed.d.ts.map +0 -1
- package/lib/typescript/utils/computed-with-auto-fill-data.d.ts.map +0 -1
- package/lib/typescript/utils/deal-with-animation.d.ts +0 -3
- package/lib/typescript/utils/deal-with-animation.d.ts.map +0 -1
- package/lib/typescript/utils/handleroffset-direction.d.ts +0 -4
- package/lib/typescript/utils/handleroffset-direction.d.ts.map +0 -1
- package/lib/typescript/utils/log.d.ts.map +0 -1
- package/lib/typescript/utils/sanitize-animation-style.d.ts.map +0 -1
- package/src/components/Carousel.test.tsx +0 -1215
- package/src/components/LazyView.test.tsx +0 -61
- package/src/components/Pagination/Basic/PaginationItem.tsx +0 -149
- package/src/components/Pagination/Basic/index.tsx +0 -98
- package/src/components/Pagination/Custom/PaginationItem.tsx +0 -166
- package/src/components/Pagination/Custom/index.tsx +0 -111
- package/src/components/Pagination/Pagination.test.tsx +0 -178
- package/src/components/ScrollViewGesture.test.tsx +0 -155
- package/src/components/issue-899-parallax-reverse-loop.test.tsx +0 -131
- package/src/components/rnr-demo.test.tsx +0 -53
- package/src/hooks/useAutoPlay.test.ts +0 -194
- package/src/hooks/useCarouselController.test.tsx +0 -1158
- package/src/hooks/useCheckMounted.test.ts +0 -47
- package/src/hooks/useCommonVariables.test.tsx +0 -384
- package/src/hooks/useInitProps.test.tsx +0 -134
- package/src/hooks/useLayoutConfig.test.tsx +0 -247
- package/src/hooks/useOffsetX.test.ts +0 -54
- package/src/hooks/useOnProgressChange.test.tsx +0 -270
- package/src/hooks/usePanGestureProxy.test.tsx +0 -368
- package/src/hooks/usePropsErrorBoundary.test.tsx +0 -57
- package/src/hooks/useUpdateGestureConfig.test.ts +0 -89
- package/src/hooks/useVisibleRanges.test.tsx +0 -347
- package/src/layouts/parallax.test.ts +0 -239
- package/src/layouts/stack.test.ts +0 -252
- package/src/store/index.test.tsx +0 -314
- package/src/utils/compute-gesture-translation.test.ts +0 -70
- package/src/utils/compute-offset-if-data-changed.test.ts +0 -133
- package/src/utils/compute-offset-if-data-changed.ts +0 -44
- package/src/utils/compute-offset-if-size-changed.test.ts +0 -78
- package/src/utils/computed-with-auto-fill-data.test.ts +0 -298
- package/src/utils/deal-with-animation.test.ts +0 -181
- package/src/utils/handleroffset-direction.test.ts +0 -124
- package/src/utils/handleroffset-direction.ts +0 -18
- package/src/utils/index.test.ts +0 -90
- package/src/utils/log.test.ts +0 -134
- package/src/utils/sanitize-animation-style.test.ts +0 -40
- /package/lib/typescript/{components → commonjs/components}/LazyView.d.ts +0 -0
- /package/lib/typescript/{constants → commonjs/constants}/index.d.ts +0 -0
- /package/lib/typescript/{hooks → commonjs/hooks}/useCheckMounted.d.ts +0 -0
- /package/lib/typescript/{utils → commonjs/utils}/compute-gesture-translation.d.ts +0 -0
- /package/lib/typescript/{utils → commonjs/utils}/compute-offset-if-size-changed.d.ts +0 -0
- /package/lib/typescript/{utils → commonjs/utils}/computed-with-auto-fill-data.d.ts +0 -0
- /package/lib/typescript/{utils → commonjs/utils}/log.d.ts +0 -0
- /package/lib/typescript/{utils → commonjs/utils}/sanitize-animation-style.d.ts +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PropsWithChildren } from "react";
|
|
2
2
|
import React, { useCallback } from "react";
|
|
3
|
-
import type { LayoutChangeEvent,
|
|
3
|
+
import type { LayoutChangeEvent, ViewProps } from "react-native";
|
|
4
4
|
import type {
|
|
5
5
|
GestureStateChangeEvent,
|
|
6
6
|
PanGestureHandlerEventPayload,
|
|
@@ -13,13 +13,12 @@ import Animated, {
|
|
|
13
13
|
useSharedValue,
|
|
14
14
|
withDecay,
|
|
15
15
|
} from "react-native-reanimated";
|
|
16
|
-
import type { SharedValue } from "react-native-reanimated";
|
|
16
|
+
import type { AnimatedProps, SharedValue } from "react-native-reanimated";
|
|
17
17
|
import { scheduleOnRN } from "react-native-worklets";
|
|
18
18
|
|
|
19
|
-
import { Easing } from "../constants";
|
|
20
19
|
import { usePanGestureProxy } from "../hooks/usePanGestureProxy";
|
|
21
20
|
import { useGlobalState } from "../store";
|
|
22
|
-
import
|
|
21
|
+
import { toLogicalGestureValue } from "../utils/carousel-direction";
|
|
23
22
|
import { computeGestureTranslation } from "../utils/compute-gesture-translation";
|
|
24
23
|
import { dealWithAnimation } from "../utils/deal-with-animation";
|
|
25
24
|
|
|
@@ -27,9 +26,8 @@ interface Props {
|
|
|
27
26
|
size: number;
|
|
28
27
|
infinite?: boolean;
|
|
29
28
|
testID?: string;
|
|
30
|
-
style?:
|
|
29
|
+
style?: AnimatedProps<ViewProps>["style"];
|
|
31
30
|
translation: SharedValue<number>;
|
|
32
|
-
onLayout?: (e: LayoutChangeEvent) => void;
|
|
33
31
|
onScrollStart?: () => void;
|
|
34
32
|
onScrollEnd?: () => void;
|
|
35
33
|
onTouchBegin?: () => void;
|
|
@@ -40,18 +38,14 @@ const IScrollViewGesture: React.FC<PropsWithChildren<Props>> = (props) => {
|
|
|
40
38
|
const {
|
|
41
39
|
props: {
|
|
42
40
|
onConfigurePanGesture,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
snapEnabled,
|
|
41
|
+
orientation,
|
|
42
|
+
snapMode,
|
|
46
43
|
loop,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
enabled,
|
|
44
|
+
animation,
|
|
45
|
+
scrollEnabled,
|
|
50
46
|
dataLength,
|
|
51
47
|
overscrollEnabled,
|
|
52
|
-
|
|
53
|
-
minScrollDistancePerSwipe,
|
|
54
|
-
fixedDirection,
|
|
48
|
+
directionSign,
|
|
55
49
|
},
|
|
56
50
|
common: { size, resolvedSize, sizePhase, sizeExplicit },
|
|
57
51
|
layout: { containerSize, updateContainerSize },
|
|
@@ -66,17 +60,17 @@ const IScrollViewGesture: React.FC<PropsWithChildren<Props>> = (props) => {
|
|
|
66
60
|
onTouchBegin,
|
|
67
61
|
onTouchEnd,
|
|
68
62
|
} = props;
|
|
63
|
+
const isVertical = orientation === "vertical";
|
|
69
64
|
|
|
70
65
|
const maxPage = dataLength;
|
|
71
|
-
const isHorizontal = useDerivedValue(() => !
|
|
66
|
+
const isHorizontal = useDerivedValue(() => !isVertical, [isVertical]);
|
|
72
67
|
const max = useSharedValue(0);
|
|
73
68
|
const panOffset = useSharedValue<number | undefined>(undefined); // set to undefined when not actively in a pan gesture
|
|
74
69
|
const touching = useSharedValue(false);
|
|
75
70
|
const validStart = useSharedValue(false);
|
|
71
|
+
const hasStartedMovement = useSharedValue(false);
|
|
76
72
|
const scrollEndTranslation = useSharedValue(0);
|
|
77
73
|
const scrollEndVelocity = useSharedValue(0);
|
|
78
|
-
const maxScrollDistancePerSwipeIsSet = typeof maxScrollDistancePerSwipe === "number";
|
|
79
|
-
const minScrollDistancePerSwipeIsSet = typeof minScrollDistancePerSwipe === "number";
|
|
80
74
|
const sizeReady = useDerivedValue(() => {
|
|
81
75
|
const currentSize = resolvedSize.value ?? 0;
|
|
82
76
|
return sizePhase.value === "ready" && currentSize > 0;
|
|
@@ -89,7 +83,7 @@ const IScrollViewGesture: React.FC<PropsWithChildren<Props>> = (props) => {
|
|
|
89
83
|
if (size <= 0) return 0;
|
|
90
84
|
|
|
91
85
|
if (!loop && !overscrollEnabled) {
|
|
92
|
-
const containerMainAxisSize =
|
|
86
|
+
const containerMainAxisSize = isVertical
|
|
93
87
|
? containerSize.value.height
|
|
94
88
|
: containerSize.value.width;
|
|
95
89
|
|
|
@@ -101,28 +95,17 @@ const IScrollViewGesture: React.FC<PropsWithChildren<Props>> = (props) => {
|
|
|
101
95
|
}
|
|
102
96
|
|
|
103
97
|
return dataLength * size;
|
|
104
|
-
}, [loop, size, dataLength, overscrollEnabled,
|
|
98
|
+
}, [loop, size, dataLength, overscrollEnabled, isVertical, containerSize]);
|
|
105
99
|
|
|
106
100
|
const withSpring = React.useCallback(
|
|
107
101
|
(toValue: number, onFinished?: () => void) => {
|
|
108
102
|
"worklet";
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
easing: Easing.easeOutQuart,
|
|
114
|
-
},
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
return dealWithAnimation(withAnimation ?? defaultWithAnimation)(
|
|
118
|
-
toValue,
|
|
119
|
-
(isFinished: boolean) => {
|
|
120
|
-
"worklet";
|
|
121
|
-
if (isFinished) onFinished && scheduleOnRN(onFinished);
|
|
122
|
-
}
|
|
123
|
-
);
|
|
103
|
+
return dealWithAnimation(animation)(toValue, (isFinished: boolean) => {
|
|
104
|
+
"worklet";
|
|
105
|
+
if (isFinished) onFinished && scheduleOnRN(onFinished);
|
|
106
|
+
});
|
|
124
107
|
},
|
|
125
|
-
[
|
|
108
|
+
[animation]
|
|
126
109
|
);
|
|
127
110
|
|
|
128
111
|
const endWithSpring = React.useCallback(
|
|
@@ -141,66 +124,54 @@ const IScrollViewGesture: React.FC<PropsWithChildren<Props>> = (props) => {
|
|
|
141
124
|
const origin = translation.value;
|
|
142
125
|
const velocity = scrollEndVelocityValue;
|
|
143
126
|
// Default to scroll in the direction of the slide (with deceleration)
|
|
144
|
-
let finalTranslation: number = withDecay({ velocity, deceleration: 0.999 })
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
* If direction is vertical, the page size is the height of the item.
|
|
156
|
-
* If direction is horizontal, the page size is the width of the item.
|
|
157
|
-
*
|
|
158
|
-
* `page size` equals to `currentSize` variable.
|
|
159
|
-
* */
|
|
160
|
-
|
|
161
|
-
// calculate target "nextPage" based on the final pan position and the velocity of
|
|
162
|
-
// the pan gesture at termination; this allows for a quick "flick" to indicate a far
|
|
163
|
-
// off page change.
|
|
164
|
-
const nextPage = -Math.round((origin + velocity * 2) / currentSize);
|
|
165
|
-
|
|
166
|
-
if (pagingEnabled) {
|
|
167
|
-
// we'll never go further than a single page away from the current page when paging
|
|
168
|
-
// is enabled.
|
|
169
|
-
|
|
170
|
-
// distance with direction
|
|
171
|
-
const offset = -(scrollEndTranslationValue >= 0 ? 1 : -1); // 1 or -1
|
|
172
|
-
const computed = offset < 0 ? Math.ceil : Math.floor;
|
|
173
|
-
const page = computed(-origin / currentSize);
|
|
174
|
-
|
|
175
|
-
const velocityDirection = -Math.sign(velocity);
|
|
176
|
-
if (page === nextPage || velocityDirection !== offset) {
|
|
177
|
-
// not going anywhere! Velocity was insufficient to overcome the distance to get to a
|
|
178
|
-
// further page. Let's reset gently to the current page.
|
|
179
|
-
finalTranslation = withSpring(withProcessTranslation(-page * currentSize), onFinished);
|
|
180
|
-
} else if (loop) {
|
|
181
|
-
const finalPage = page + offset;
|
|
182
|
-
finalTranslation = withSpring(
|
|
183
|
-
withProcessTranslation(-finalPage * currentSize),
|
|
184
|
-
onFinished
|
|
185
|
-
);
|
|
186
|
-
} else {
|
|
187
|
-
const finalPage = Math.min(maxPage - 1, Math.max(0, page + offset));
|
|
188
|
-
finalTranslation = withSpring(
|
|
189
|
-
withProcessTranslation(-finalPage * currentSize),
|
|
190
|
-
onFinished
|
|
191
|
-
);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
127
|
+
let finalTranslation: number = withDecay({ velocity, deceleration: 0.999 }, (isFinished) => {
|
|
128
|
+
if (isFinished && onFinished) scheduleOnRN(onFinished);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* The page size is the same as the item size.
|
|
133
|
+
* If direction is vertical, the page size is the height of the item.
|
|
134
|
+
* If direction is horizontal, the page size is the width of the item.
|
|
135
|
+
*
|
|
136
|
+
* `page size` equals to `currentSize` variable.
|
|
137
|
+
*/
|
|
194
138
|
|
|
195
|
-
|
|
196
|
-
|
|
139
|
+
// Calculate target based on final pan position and velocity.
|
|
140
|
+
const nextPage = -Math.round((origin + velocity * 2) / currentSize);
|
|
141
|
+
|
|
142
|
+
if (snapMode === "page") {
|
|
143
|
+
// we'll never go further than a single page away from the current page when paging
|
|
144
|
+
// is enabled.
|
|
145
|
+
|
|
146
|
+
// distance with direction
|
|
147
|
+
const offset = -(scrollEndTranslationValue >= 0 ? 1 : -1); // 1 or -1
|
|
148
|
+
const computed = offset < 0 ? Math.ceil : Math.floor;
|
|
149
|
+
const page = computed(-origin / currentSize);
|
|
150
|
+
|
|
151
|
+
const velocityDirection = -Math.sign(velocity);
|
|
152
|
+
if (page === nextPage || velocityDirection !== offset) {
|
|
153
|
+
// not going anywhere! Velocity was insufficient to overcome the distance to get to a
|
|
154
|
+
// further page. Let's reset gently to the current page.
|
|
155
|
+
finalTranslation = withSpring(withProcessTranslation(-page * currentSize), onFinished);
|
|
156
|
+
} else if (loop) {
|
|
157
|
+
const finalPage = page + offset;
|
|
158
|
+
finalTranslation = withSpring(
|
|
159
|
+
withProcessTranslation(-finalPage * currentSize),
|
|
160
|
+
onFinished
|
|
161
|
+
);
|
|
162
|
+
} else {
|
|
163
|
+
const finalPage = Math.min(maxPage - 1, Math.max(0, page + offset));
|
|
197
164
|
finalTranslation = withSpring(
|
|
198
|
-
withProcessTranslation(-
|
|
165
|
+
withProcessTranslation(-finalPage * currentSize),
|
|
199
166
|
onFinished
|
|
200
167
|
);
|
|
201
168
|
}
|
|
202
169
|
}
|
|
203
170
|
|
|
171
|
+
if (snapMode === "nearest") {
|
|
172
|
+
finalTranslation = withSpring(withProcessTranslation(-nextPage * currentSize), onFinished);
|
|
173
|
+
}
|
|
174
|
+
|
|
204
175
|
translation.value = finalTranslation;
|
|
205
176
|
|
|
206
177
|
function withProcessTranslation(translation: number) {
|
|
@@ -212,17 +183,7 @@ const IScrollViewGesture: React.FC<PropsWithChildren<Props>> = (props) => {
|
|
|
212
183
|
return translation;
|
|
213
184
|
}
|
|
214
185
|
},
|
|
215
|
-
[
|
|
216
|
-
withSpring,
|
|
217
|
-
resolvedSize,
|
|
218
|
-
maxPage,
|
|
219
|
-
loop,
|
|
220
|
-
snapEnabled,
|
|
221
|
-
translation,
|
|
222
|
-
pagingEnabled,
|
|
223
|
-
maxScrollDistancePerSwipe,
|
|
224
|
-
maxScrollDistancePerSwipeIsSet,
|
|
225
|
-
]
|
|
186
|
+
[withSpring, resolvedSize, maxPage, loop, snapMode, translation]
|
|
226
187
|
);
|
|
227
188
|
|
|
228
189
|
const onFinish = React.useCallback(
|
|
@@ -270,36 +231,16 @@ const IScrollViewGesture: React.FC<PropsWithChildren<Props>> = (props) => {
|
|
|
270
231
|
}
|
|
271
232
|
if (!loop) translation.value = withSpring(-((maxPage - 1) * currentSize));
|
|
272
233
|
}
|
|
273
|
-
}, [
|
|
274
|
-
touching,
|
|
275
|
-
translation,
|
|
276
|
-
maxPage,
|
|
277
|
-
resolvedSize,
|
|
278
|
-
scrollEndTranslation,
|
|
279
|
-
loop,
|
|
280
|
-
activeDecay,
|
|
281
|
-
withSpring,
|
|
282
|
-
]);
|
|
234
|
+
}, [touching, translation, resolvedSize, scrollEndTranslation, loop, activeDecay, withSpring]);
|
|
283
235
|
|
|
284
236
|
useAnimatedReaction(
|
|
285
237
|
() => translation.value,
|
|
286
238
|
() => {
|
|
287
|
-
if (
|
|
239
|
+
if (snapMode !== "page") resetBoundary();
|
|
288
240
|
},
|
|
289
|
-
[
|
|
241
|
+
[resetBoundary, snapMode]
|
|
290
242
|
);
|
|
291
243
|
|
|
292
|
-
function withProcessTranslation(translation: number) {
|
|
293
|
-
"worklet";
|
|
294
|
-
|
|
295
|
-
if (!loop && !overscrollEnabled) {
|
|
296
|
-
const limit = getLimit();
|
|
297
|
-
return Math.min(0, Math.max(-limit, translation));
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
return translation;
|
|
301
|
-
}
|
|
302
|
-
|
|
303
244
|
const onGestureStart = useCallback(
|
|
304
245
|
(_: PanGestureHandlerEventPayload) => {
|
|
305
246
|
"worklet";
|
|
@@ -311,7 +252,7 @@ const IScrollViewGesture: React.FC<PropsWithChildren<Props>> = (props) => {
|
|
|
311
252
|
}
|
|
312
253
|
touching.value = true;
|
|
313
254
|
validStart.value = true;
|
|
314
|
-
|
|
255
|
+
hasStartedMovement.value = false;
|
|
315
256
|
|
|
316
257
|
max.value = (maxPage - 1) * currentSize;
|
|
317
258
|
if (!loop && !overscrollEnabled) max.value = getLimit();
|
|
@@ -328,7 +269,7 @@ const IScrollViewGesture: React.FC<PropsWithChildren<Props>> = (props) => {
|
|
|
328
269
|
translation,
|
|
329
270
|
overscrollEnabled,
|
|
330
271
|
getLimit,
|
|
331
|
-
|
|
272
|
+
hasStartedMovement,
|
|
332
273
|
sizeReady,
|
|
333
274
|
resolvedSize,
|
|
334
275
|
]
|
|
@@ -362,10 +303,12 @@ const IScrollViewGesture: React.FC<PropsWithChildren<Props>> = (props) => {
|
|
|
362
303
|
touching.value = true;
|
|
363
304
|
const { translationX, translationY } = e;
|
|
364
305
|
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
if (
|
|
368
|
-
|
|
306
|
+
const physicalPanTranslation = isHorizontal.value ? translationX : translationY;
|
|
307
|
+
const panTranslation = toLogicalGestureValue(physicalPanTranslation, directionSign);
|
|
308
|
+
if (!hasStartedMovement.value && panTranslation !== 0) {
|
|
309
|
+
hasStartedMovement.value = true;
|
|
310
|
+
if (onScrollStart) scheduleOnRN(onScrollStart);
|
|
311
|
+
}
|
|
369
312
|
|
|
370
313
|
translation.value = computeGestureTranslation({
|
|
371
314
|
loop,
|
|
@@ -382,12 +325,14 @@ const IScrollViewGesture: React.FC<PropsWithChildren<Props>> = (props) => {
|
|
|
382
325
|
panOffset,
|
|
383
326
|
loop,
|
|
384
327
|
overscrollEnabled,
|
|
385
|
-
|
|
328
|
+
hasStartedMovement,
|
|
329
|
+
onScrollStart,
|
|
386
330
|
translation,
|
|
387
331
|
validStart,
|
|
388
332
|
touching,
|
|
389
333
|
sizeReady,
|
|
390
334
|
resolvedSize,
|
|
335
|
+
directionSign,
|
|
391
336
|
]
|
|
392
337
|
);
|
|
393
338
|
|
|
@@ -407,50 +352,23 @@ const IScrollViewGesture: React.FC<PropsWithChildren<Props>> = (props) => {
|
|
|
407
352
|
return;
|
|
408
353
|
}
|
|
409
354
|
|
|
355
|
+
if (!hasStartedMovement.value) {
|
|
356
|
+
touching.value = false;
|
|
357
|
+
panOffset.value = undefined;
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
|
|
410
361
|
const { velocityX, velocityY, translationX, translationY } = e;
|
|
411
|
-
const
|
|
362
|
+
const physicalVelocity = isHorizontal.value ? velocityX : velocityY;
|
|
363
|
+
const scrollEndVelocityValue = toLogicalGestureValue(physicalVelocity, directionSign);
|
|
412
364
|
scrollEndVelocity.value = scrollEndVelocityValue; // may update async: see https://docs.swmansion.com/react-native-reanimated/docs/core/useSharedValue#remarks
|
|
413
365
|
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
if (fixedDirection === "negative") panTranslation = -Math.abs(panTranslation);
|
|
417
|
-
else if (fixedDirection === "positive") panTranslation = +Math.abs(panTranslation);
|
|
366
|
+
const physicalPanTranslation = isHorizontal.value ? translationX : translationY;
|
|
367
|
+
const panTranslation = toLogicalGestureValue(physicalPanTranslation, directionSign);
|
|
418
368
|
|
|
419
369
|
scrollEndTranslation.value = panTranslation; // may update async: see https://docs.swmansion.com/react-native-reanimated/docs/core/useSharedValue#remarks
|
|
420
370
|
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
/**
|
|
424
|
-
* If the maximum scroll distance is set and the translation `exceeds the maximum scroll distance`,
|
|
425
|
-
* the carousel will keep the view at the current position.
|
|
426
|
-
*/
|
|
427
|
-
if (
|
|
428
|
-
maxScrollDistancePerSwipeIsSet &&
|
|
429
|
-
Math.abs(totalTranslation) > maxScrollDistancePerSwipe
|
|
430
|
-
) {
|
|
431
|
-
const nextPage =
|
|
432
|
-
Math.round(
|
|
433
|
-
(panOffset.value + maxScrollDistancePerSwipe * Math.sign(totalTranslation)) /
|
|
434
|
-
currentSize
|
|
435
|
-
) * currentSize;
|
|
436
|
-
translation.value = withSpring(withProcessTranslation(nextPage), onScrollEnd);
|
|
437
|
-
} else if (
|
|
438
|
-
/**
|
|
439
|
-
* If the minimum scroll distance is set and the translation `didn't exceeds the minimum scroll distance`,
|
|
440
|
-
* the carousel will keep the view at the current position.
|
|
441
|
-
*/
|
|
442
|
-
minScrollDistancePerSwipeIsSet &&
|
|
443
|
-
Math.abs(totalTranslation) < minScrollDistancePerSwipe
|
|
444
|
-
) {
|
|
445
|
-
const nextPage =
|
|
446
|
-
Math.round(
|
|
447
|
-
(panOffset.value + minScrollDistancePerSwipe * Math.sign(totalTranslation)) /
|
|
448
|
-
currentSize
|
|
449
|
-
) * currentSize;
|
|
450
|
-
translation.value = withSpring(withProcessTranslation(nextPage), onScrollEnd);
|
|
451
|
-
} else {
|
|
452
|
-
endWithSpring(panTranslation, scrollEndVelocityValue, onScrollEnd);
|
|
453
|
-
}
|
|
371
|
+
endWithSpring(panTranslation, scrollEndVelocityValue, onScrollEnd);
|
|
454
372
|
|
|
455
373
|
if (!loop) touching.value = false;
|
|
456
374
|
|
|
@@ -464,16 +382,12 @@ const IScrollViewGesture: React.FC<PropsWithChildren<Props>> = (props) => {
|
|
|
464
382
|
isHorizontal,
|
|
465
383
|
scrollEndVelocity,
|
|
466
384
|
scrollEndTranslation,
|
|
467
|
-
fixedDirection,
|
|
468
|
-
maxScrollDistancePerSwipeIsSet,
|
|
469
|
-
maxScrollDistancePerSwipe,
|
|
470
|
-
minScrollDistancePerSwipeIsSet,
|
|
471
|
-
minScrollDistancePerSwipe,
|
|
472
385
|
endWithSpring,
|
|
473
|
-
withSpring,
|
|
474
386
|
onScrollEnd,
|
|
387
|
+
hasStartedMovement,
|
|
475
388
|
sizeReady,
|
|
476
389
|
resolvedSize,
|
|
390
|
+
directionSign,
|
|
477
391
|
]
|
|
478
392
|
);
|
|
479
393
|
|
|
@@ -482,7 +396,7 @@ const IScrollViewGesture: React.FC<PropsWithChildren<Props>> = (props) => {
|
|
|
482
396
|
onGestureStart,
|
|
483
397
|
onGestureUpdate,
|
|
484
398
|
onGestureEnd,
|
|
485
|
-
options: { enabled },
|
|
399
|
+
options: { enabled: scrollEnabled },
|
|
486
400
|
});
|
|
487
401
|
|
|
488
402
|
const onLayout = React.useCallback(
|
|
@@ -491,7 +405,7 @@ const IScrollViewGesture: React.FC<PropsWithChildren<Props>> = (props) => {
|
|
|
491
405
|
|
|
492
406
|
const measuredWidth = e.nativeEvent.layout.width;
|
|
493
407
|
const measuredHeight = e.nativeEvent.layout.height;
|
|
494
|
-
const measuredSize = Math.round((
|
|
408
|
+
const measuredSize = Math.round((isVertical ? measuredHeight : measuredWidth) || 0);
|
|
495
409
|
|
|
496
410
|
if (!sizeExplicit && measuredSize > 0) {
|
|
497
411
|
const current = resolvedSize.value ?? 0;
|
|
@@ -507,7 +421,7 @@ const IScrollViewGesture: React.FC<PropsWithChildren<Props>> = (props) => {
|
|
|
507
421
|
height: measuredHeight,
|
|
508
422
|
});
|
|
509
423
|
},
|
|
510
|
-
[updateContainerSize, resolvedSize, sizePhase,
|
|
424
|
+
[updateContainerSize, resolvedSize, sizePhase, isVertical, sizeExplicit]
|
|
511
425
|
);
|
|
512
426
|
|
|
513
427
|
return (
|
|
@@ -517,6 +431,7 @@ const IScrollViewGesture: React.FC<PropsWithChildren<Props>> = (props) => {
|
|
|
517
431
|
style={style}
|
|
518
432
|
onTouchStart={onTouchBegin}
|
|
519
433
|
onTouchEnd={onTouchEnd}
|
|
434
|
+
onTouchCancel={onTouchEnd}
|
|
520
435
|
onLayout={onLayout}
|
|
521
436
|
>
|
|
522
437
|
{props.children}
|
package/src/hooks/useAutoPlay.ts
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type { CarouselController } from "./useCarouselController";
|
|
4
4
|
|
|
5
|
-
export function useAutoPlay(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
carouselController:
|
|
5
|
+
export function useAutoPlay(options: {
|
|
6
|
+
autoplay?: boolean;
|
|
7
|
+
autoplayInterval?: number;
|
|
8
|
+
autoplayDirection?: "forward" | "backward";
|
|
9
|
+
carouselController: CarouselController;
|
|
10
10
|
}) {
|
|
11
|
-
const {
|
|
12
|
-
|
|
11
|
+
const {
|
|
12
|
+
autoplay = false,
|
|
13
|
+
autoplayDirection = "forward",
|
|
14
|
+
autoplayInterval,
|
|
15
|
+
carouselController,
|
|
16
|
+
} = options;
|
|
13
17
|
const { prev, next } = carouselController;
|
|
14
18
|
const timer = React.useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
15
|
-
const stopped = React.useRef
|
|
19
|
+
const stopped = React.useRef(!autoplay);
|
|
16
20
|
|
|
17
21
|
const play = React.useCallback(() => {
|
|
18
22
|
if (stopped.current) return;
|
|
@@ -22,33 +26,34 @@ export function useAutoPlay(opts: {
|
|
|
22
26
|
timer.current = null;
|
|
23
27
|
}
|
|
24
28
|
timer.current = setTimeout(() => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
if (autoplayDirection === "backward") prev({ onFinished: play });
|
|
30
|
+
else next({ onFinished: play });
|
|
31
|
+
}, autoplayInterval);
|
|
32
|
+
}, [autoplayDirection, autoplayInterval, next, prev]);
|
|
28
33
|
|
|
29
34
|
const pause = React.useCallback(() => {
|
|
30
|
-
if (!
|
|
35
|
+
if (!autoplay) return;
|
|
31
36
|
|
|
32
37
|
if (timer.current) {
|
|
33
38
|
clearTimeout(timer.current);
|
|
34
39
|
timer.current = null;
|
|
35
40
|
}
|
|
36
41
|
stopped.current = true;
|
|
37
|
-
}, [
|
|
42
|
+
}, [autoplay]);
|
|
38
43
|
|
|
39
44
|
const start = React.useCallback(() => {
|
|
40
|
-
if (!
|
|
45
|
+
if (!autoplay) return;
|
|
41
46
|
|
|
42
47
|
stopped.current = false;
|
|
43
48
|
play();
|
|
44
|
-
}, [
|
|
49
|
+
}, [autoplay, play]);
|
|
45
50
|
|
|
46
51
|
React.useEffect(() => {
|
|
47
|
-
if (
|
|
52
|
+
if (autoplay) start();
|
|
48
53
|
else pause();
|
|
49
54
|
|
|
50
55
|
return pause;
|
|
51
|
-
}, [pause, start
|
|
56
|
+
}, [autoplay, pause, start]);
|
|
52
57
|
|
|
53
58
|
return {
|
|
54
59
|
pause,
|