@leonsilicon/react-native-reanimated-carousel 0.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/LICENSE +21 -0
- package/README.md +652 -0
- package/lib/commonjs/components/Carousel.js +2 -0
- package/lib/commonjs/components/Carousel.js.map +1 -0
- package/lib/commonjs/components/CarouselLayout.js +2 -0
- package/lib/commonjs/components/CarouselLayout.js.map +1 -0
- package/lib/commonjs/components/ItemLayout.js +2 -0
- package/lib/commonjs/components/ItemLayout.js.map +1 -0
- package/lib/commonjs/components/ItemRenderer.js +2 -0
- package/lib/commonjs/components/ItemRenderer.js.map +1 -0
- package/lib/commonjs/components/LazyView.js +2 -0
- package/lib/commonjs/components/LazyView.js.map +1 -0
- package/lib/commonjs/components/Pagination/Basic/PaginationItem.js +2 -0
- package/lib/commonjs/components/Pagination/Basic/PaginationItem.js.map +1 -0
- package/lib/commonjs/components/Pagination/Basic/index.js +2 -0
- package/lib/commonjs/components/Pagination/Basic/index.js.map +1 -0
- package/lib/commonjs/components/Pagination/Custom/PaginationItem.js +2 -0
- package/lib/commonjs/components/Pagination/Custom/PaginationItem.js.map +1 -0
- package/lib/commonjs/components/Pagination/Custom/index.js +2 -0
- package/lib/commonjs/components/Pagination/Custom/index.js.map +1 -0
- package/lib/commonjs/components/Pagination/index.js +2 -0
- package/lib/commonjs/components/Pagination/index.js.map +1 -0
- package/lib/commonjs/components/ScrollViewGesture.js +2 -0
- package/lib/commonjs/components/ScrollViewGesture.js.map +1 -0
- package/lib/commonjs/constants/index.js +2 -0
- package/lib/commonjs/constants/index.js.map +1 -0
- package/lib/commonjs/hooks/useAutoPlay.js +2 -0
- package/lib/commonjs/hooks/useAutoPlay.js.map +1 -0
- package/lib/commonjs/hooks/useCarouselController.js +2 -0
- package/lib/commonjs/hooks/useCarouselController.js.map +1 -0
- package/lib/commonjs/hooks/useCheckMounted.js +2 -0
- package/lib/commonjs/hooks/useCheckMounted.js.map +1 -0
- package/lib/commonjs/hooks/useCommonVariables.js +2 -0
- package/lib/commonjs/hooks/useCommonVariables.js.map +1 -0
- package/lib/commonjs/hooks/useInitProps.js +2 -0
- package/lib/commonjs/hooks/useInitProps.js.map +1 -0
- package/lib/commonjs/hooks/useLayoutConfig.js +2 -0
- package/lib/commonjs/hooks/useLayoutConfig.js.map +1 -0
- package/lib/commonjs/hooks/useOffsetX.js +2 -0
- package/lib/commonjs/hooks/useOffsetX.js.map +1 -0
- package/lib/commonjs/hooks/useOnProgressChange.js +2 -0
- package/lib/commonjs/hooks/useOnProgressChange.js.map +1 -0
- package/lib/commonjs/hooks/usePanGestureProxy.js +2 -0
- package/lib/commonjs/hooks/usePanGestureProxy.js.map +1 -0
- package/lib/commonjs/hooks/usePropsErrorBoundary.js +2 -0
- package/lib/commonjs/hooks/usePropsErrorBoundary.js.map +1 -0
- package/lib/commonjs/hooks/useSizeResolver.js +2 -0
- package/lib/commonjs/hooks/useSizeResolver.js.map +1 -0
- package/lib/commonjs/hooks/useUpdateGestureConfig.js +2 -0
- package/lib/commonjs/hooks/useUpdateGestureConfig.js.map +1 -0
- package/lib/commonjs/hooks/useVisibleRanges.js +2 -0
- package/lib/commonjs/hooks/useVisibleRanges.js.map +1 -0
- package/lib/commonjs/index.js +2 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/layouts/index.js +2 -0
- package/lib/commonjs/layouts/index.js.map +1 -0
- package/lib/commonjs/layouts/normal.js +2 -0
- package/lib/commonjs/layouts/normal.js.map +1 -0
- package/lib/commonjs/layouts/parallax.js +2 -0
- package/lib/commonjs/layouts/parallax.js.map +1 -0
- package/lib/commonjs/layouts/stack.js +2 -0
- package/lib/commonjs/layouts/stack.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/store/index.js +2 -0
- package/lib/commonjs/store/index.js.map +1 -0
- package/lib/commonjs/types.js +2 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/commonjs/utils/compute-gesture-translation.js +2 -0
- package/lib/commonjs/utils/compute-gesture-translation.js.map +1 -0
- package/lib/commonjs/utils/compute-offset-if-data-changed.js +2 -0
- package/lib/commonjs/utils/compute-offset-if-data-changed.js.map +1 -0
- package/lib/commonjs/utils/compute-offset-if-size-changed.js +2 -0
- package/lib/commonjs/utils/compute-offset-if-size-changed.js.map +1 -0
- package/lib/commonjs/utils/compute-offset-if-sizes-changed.js +2 -0
- package/lib/commonjs/utils/compute-offset-if-sizes-changed.js.map +1 -0
- package/lib/commonjs/utils/computed-with-auto-fill-data.js +2 -0
- package/lib/commonjs/utils/computed-with-auto-fill-data.js.map +1 -0
- package/lib/commonjs/utils/deal-with-animation.js +2 -0
- package/lib/commonjs/utils/deal-with-animation.js.map +1 -0
- package/lib/commonjs/utils/handleroffset-direction.js +2 -0
- package/lib/commonjs/utils/handleroffset-direction.js.map +1 -0
- package/lib/commonjs/utils/log.js +2 -0
- package/lib/commonjs/utils/log.js.map +1 -0
- package/lib/commonjs/utils/sanitize-animation-style.js +2 -0
- package/lib/commonjs/utils/sanitize-animation-style.js.map +1 -0
- package/lib/commonjs/utils/size-resolver.js +2 -0
- package/lib/commonjs/utils/size-resolver.js.map +1 -0
- package/lib/module/components/Carousel.js +2 -0
- package/lib/module/components/Carousel.js.map +1 -0
- package/lib/module/components/CarouselLayout.js +2 -0
- package/lib/module/components/CarouselLayout.js.map +1 -0
- package/lib/module/components/ItemLayout.js +2 -0
- package/lib/module/components/ItemLayout.js.map +1 -0
- package/lib/module/components/ItemRenderer.js +2 -0
- package/lib/module/components/ItemRenderer.js.map +1 -0
- package/lib/module/components/LazyView.js +2 -0
- package/lib/module/components/LazyView.js.map +1 -0
- package/lib/module/components/Pagination/Basic/PaginationItem.js +2 -0
- package/lib/module/components/Pagination/Basic/PaginationItem.js.map +1 -0
- package/lib/module/components/Pagination/Basic/index.js +2 -0
- package/lib/module/components/Pagination/Basic/index.js.map +1 -0
- package/lib/module/components/Pagination/Custom/PaginationItem.js +2 -0
- package/lib/module/components/Pagination/Custom/PaginationItem.js.map +1 -0
- package/lib/module/components/Pagination/Custom/index.js +2 -0
- package/lib/module/components/Pagination/Custom/index.js.map +1 -0
- package/lib/module/components/Pagination/index.js +2 -0
- package/lib/module/components/Pagination/index.js.map +1 -0
- package/lib/module/components/ScrollViewGesture.js +2 -0
- package/lib/module/components/ScrollViewGesture.js.map +1 -0
- package/lib/module/constants/index.js +2 -0
- package/lib/module/constants/index.js.map +1 -0
- package/lib/module/hooks/useAutoPlay.js +2 -0
- package/lib/module/hooks/useAutoPlay.js.map +1 -0
- package/lib/module/hooks/useCarouselController.js +2 -0
- package/lib/module/hooks/useCarouselController.js.map +1 -0
- package/lib/module/hooks/useCheckMounted.js +2 -0
- package/lib/module/hooks/useCheckMounted.js.map +1 -0
- package/lib/module/hooks/useCommonVariables.js +2 -0
- package/lib/module/hooks/useCommonVariables.js.map +1 -0
- package/lib/module/hooks/useInitProps.js +2 -0
- package/lib/module/hooks/useInitProps.js.map +1 -0
- package/lib/module/hooks/useLayoutConfig.js +2 -0
- package/lib/module/hooks/useLayoutConfig.js.map +1 -0
- package/lib/module/hooks/useOffsetX.js +2 -0
- package/lib/module/hooks/useOffsetX.js.map +1 -0
- package/lib/module/hooks/useOnProgressChange.js +2 -0
- package/lib/module/hooks/useOnProgressChange.js.map +1 -0
- package/lib/module/hooks/usePanGestureProxy.js +2 -0
- package/lib/module/hooks/usePanGestureProxy.js.map +1 -0
- package/lib/module/hooks/usePropsErrorBoundary.js +2 -0
- package/lib/module/hooks/usePropsErrorBoundary.js.map +1 -0
- package/lib/module/hooks/useSizeResolver.js +2 -0
- package/lib/module/hooks/useSizeResolver.js.map +1 -0
- package/lib/module/hooks/useUpdateGestureConfig.js +2 -0
- package/lib/module/hooks/useUpdateGestureConfig.js.map +1 -0
- package/lib/module/hooks/useVisibleRanges.js +2 -0
- package/lib/module/hooks/useVisibleRanges.js.map +1 -0
- package/lib/module/index.js +2 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/layouts/index.js +2 -0
- package/lib/module/layouts/index.js.map +1 -0
- package/lib/module/layouts/normal.js +2 -0
- package/lib/module/layouts/normal.js.map +1 -0
- package/lib/module/layouts/parallax.js +2 -0
- package/lib/module/layouts/parallax.js.map +1 -0
- package/lib/module/layouts/stack.js +2 -0
- package/lib/module/layouts/stack.js.map +1 -0
- package/lib/module/store/index.js +2 -0
- package/lib/module/store/index.js.map +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/utils/compute-gesture-translation.js +2 -0
- package/lib/module/utils/compute-gesture-translation.js.map +1 -0
- package/lib/module/utils/compute-offset-if-data-changed.js +2 -0
- package/lib/module/utils/compute-offset-if-data-changed.js.map +1 -0
- package/lib/module/utils/compute-offset-if-size-changed.js +2 -0
- package/lib/module/utils/compute-offset-if-size-changed.js.map +1 -0
- package/lib/module/utils/compute-offset-if-sizes-changed.js +2 -0
- package/lib/module/utils/compute-offset-if-sizes-changed.js.map +1 -0
- package/lib/module/utils/computed-with-auto-fill-data.js +2 -0
- package/lib/module/utils/computed-with-auto-fill-data.js.map +1 -0
- package/lib/module/utils/deal-with-animation.js +2 -0
- package/lib/module/utils/deal-with-animation.js.map +1 -0
- package/lib/module/utils/handleroffset-direction.js +2 -0
- package/lib/module/utils/handleroffset-direction.js.map +1 -0
- package/lib/module/utils/log.js +2 -0
- package/lib/module/utils/log.js.map +1 -0
- package/lib/module/utils/sanitize-animation-style.js +2 -0
- package/lib/module/utils/sanitize-animation-style.js.map +1 -0
- package/lib/module/utils/size-resolver.js +2 -0
- package/lib/module/utils/size-resolver.js.map +1 -0
- package/lib/typescript/components/Carousel.d.ts +8 -0
- package/lib/typescript/components/Carousel.d.ts.map +1 -0
- package/lib/typescript/components/CarouselLayout.d.ts +6 -0
- package/lib/typescript/components/CarouselLayout.d.ts.map +1 -0
- package/lib/typescript/components/ItemLayout.d.ts +15 -0
- package/lib/typescript/components/ItemLayout.d.ts.map +1 -0
- package/lib/typescript/components/ItemRenderer.d.ts +24 -0
- package/lib/typescript/components/ItemRenderer.d.ts.map +1 -0
- package/lib/typescript/components/LazyView.d.ts +8 -0
- package/lib/typescript/components/LazyView.d.ts.map +1 -0
- package/lib/typescript/components/Pagination/Basic/PaginationItem.d.ts +29 -0
- package/lib/typescript/components/Pagination/Basic/PaginationItem.d.ts.map +1 -0
- package/lib/typescript/components/Pagination/Basic/index.d.ts +23 -0
- package/lib/typescript/components/Pagination/Basic/index.d.ts.map +1 -0
- package/lib/typescript/components/Pagination/Custom/PaginationItem.d.ts +35 -0
- package/lib/typescript/components/Pagination/Custom/PaginationItem.d.ts.map +1 -0
- package/lib/typescript/components/Pagination/Custom/index.d.ts +26 -0
- package/lib/typescript/components/Pagination/Custom/index.d.ts.map +1 -0
- package/lib/typescript/components/Pagination/index.d.ts +5 -0
- package/lib/typescript/components/Pagination/index.d.ts.map +1 -0
- package/lib/typescript/components/ScrollViewGesture.d.ts +19 -0
- package/lib/typescript/components/ScrollViewGesture.d.ts.map +1 -0
- package/lib/typescript/constants/index.d.ts +9 -0
- package/lib/typescript/constants/index.d.ts.map +1 -0
- package/lib/typescript/hooks/useAutoPlay.d.ts +12 -0
- package/lib/typescript/hooks/useAutoPlay.d.ts.map +1 -0
- package/lib/typescript/hooks/useCarouselController.d.ts +28 -0
- package/lib/typescript/hooks/useCarouselController.d.ts.map +1 -0
- package/lib/typescript/hooks/useCheckMounted.d.ts +3 -0
- package/lib/typescript/hooks/useCheckMounted.d.ts.map +1 -0
- package/lib/typescript/hooks/useCommonVariables.d.ts +13 -0
- package/lib/typescript/hooks/useCommonVariables.d.ts.map +1 -0
- package/lib/typescript/hooks/useInitProps.d.ts +17 -0
- package/lib/typescript/hooks/useInitProps.d.ts.map +1 -0
- package/lib/typescript/hooks/useLayoutConfig.d.ts +10 -0
- package/lib/typescript/hooks/useLayoutConfig.d.ts.map +1 -0
- package/lib/typescript/hooks/useOffsetX.d.ts +24 -0
- package/lib/typescript/hooks/useOffsetX.d.ts.map +1 -0
- package/lib/typescript/hooks/useOnProgressChange.d.ts +14 -0
- package/lib/typescript/hooks/useOnProgressChange.d.ts.map +1 -0
- package/lib/typescript/hooks/usePanGestureProxy.d.ts +10 -0
- package/lib/typescript/hooks/usePanGestureProxy.d.ts.map +1 -0
- package/lib/typescript/hooks/usePropsErrorBoundary.d.ts +5 -0
- package/lib/typescript/hooks/usePropsErrorBoundary.d.ts.map +1 -0
- package/lib/typescript/hooks/useSizeResolver.d.ts +27 -0
- package/lib/typescript/hooks/useSizeResolver.d.ts.map +1 -0
- package/lib/typescript/hooks/useUpdateGestureConfig.d.ts +6 -0
- package/lib/typescript/hooks/useUpdateGestureConfig.d.ts.map +1 -0
- package/lib/typescript/hooks/useVisibleRanges.d.ts +23 -0
- package/lib/typescript/hooks/useVisibleRanges.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +7 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/layouts/index.d.ts +11 -0
- package/lib/typescript/layouts/index.d.ts.map +1 -0
- package/lib/typescript/layouts/normal.d.ts +16 -0
- package/lib/typescript/layouts/normal.d.ts.map +1 -0
- package/lib/typescript/layouts/parallax.d.ts +50 -0
- package/lib/typescript/layouts/parallax.d.ts.map +1 -0
- package/lib/typescript/layouts/stack.d.ts +38 -0
- package/lib/typescript/layouts/stack.d.ts.map +1 -0
- package/lib/typescript/store/index.d.ts +38 -0
- package/lib/typescript/store/index.d.ts.map +1 -0
- package/lib/typescript/types.d.ts +326 -0
- package/lib/typescript/types.d.ts.map +1 -0
- package/lib/typescript/utils/compute-gesture-translation.d.ts +9 -0
- package/lib/typescript/utils/compute-gesture-translation.d.ts.map +1 -0
- package/lib/typescript/utils/compute-offset-if-data-changed.d.ts +9 -0
- package/lib/typescript/utils/compute-offset-if-data-changed.d.ts.map +1 -0
- package/lib/typescript/utils/compute-offset-if-size-changed.d.ts +6 -0
- package/lib/typescript/utils/compute-offset-if-size-changed.d.ts.map +1 -0
- package/lib/typescript/utils/compute-offset-if-sizes-changed.d.ts +14 -0
- package/lib/typescript/utils/compute-offset-if-sizes-changed.d.ts.map +1 -0
- package/lib/typescript/utils/computed-with-auto-fill-data.d.ts +23 -0
- package/lib/typescript/utils/computed-with-auto-fill-data.d.ts.map +1 -0
- package/lib/typescript/utils/deal-with-animation.d.ts +3 -0
- package/lib/typescript/utils/deal-with-animation.d.ts.map +1 -0
- package/lib/typescript/utils/handleroffset-direction.d.ts +4 -0
- package/lib/typescript/utils/handleroffset-direction.d.ts.map +1 -0
- package/lib/typescript/utils/log.d.ts +7 -0
- package/lib/typescript/utils/log.d.ts.map +1 -0
- package/lib/typescript/utils/sanitize-animation-style.d.ts +3 -0
- package/lib/typescript/utils/sanitize-animation-style.d.ts.map +1 -0
- package/lib/typescript/utils/size-resolver.d.ts +87 -0
- package/lib/typescript/utils/size-resolver.d.ts.map +1 -0
- package/package.json +151 -0
- package/src/components/Carousel.test.tsx +1153 -0
- package/src/components/Carousel.tsx +35 -0
- package/src/components/CarouselLayout.tsx +231 -0
- package/src/components/ItemLayout.tsx +217 -0
- package/src/components/ItemRenderer.tsx +114 -0
- package/src/components/LazyView.test.tsx +61 -0
- package/src/components/LazyView.tsx +14 -0
- package/src/components/Pagination/Basic/PaginationItem.tsx +149 -0
- package/src/components/Pagination/Basic/index.tsx +98 -0
- package/src/components/Pagination/Custom/PaginationItem.tsx +166 -0
- package/src/components/Pagination/Custom/index.tsx +111 -0
- package/src/components/Pagination/Pagination.test.tsx +178 -0
- package/src/components/Pagination/index.tsx +7 -0
- package/src/components/ScrollViewGesture.tsx +577 -0
- package/src/components/rnr-demo.test.tsx +53 -0
- package/src/constants/index.ts +11 -0
- package/src/hooks/useAutoPlay.test.ts +194 -0
- package/src/hooks/useAutoPlay.ts +58 -0
- package/src/hooks/useCarouselController.test.tsx +1158 -0
- package/src/hooks/useCarouselController.tsx +525 -0
- package/src/hooks/useCheckMounted.test.ts +47 -0
- package/src/hooks/useCheckMounted.ts +14 -0
- package/src/hooks/useCommonVariables.test.tsx +384 -0
- package/src/hooks/useCommonVariables.ts +202 -0
- package/src/hooks/useInitProps.test.tsx +134 -0
- package/src/hooks/useInitProps.ts +111 -0
- package/src/hooks/useLayoutConfig.test.tsx +247 -0
- package/src/hooks/useLayoutConfig.ts +30 -0
- package/src/hooks/useOffsetX.test.ts +110 -0
- package/src/hooks/useOffsetX.ts +109 -0
- package/src/hooks/useOnProgressChange.test.tsx +207 -0
- package/src/hooks/useOnProgressChange.ts +105 -0
- package/src/hooks/usePanGestureProxy.test.tsx +368 -0
- package/src/hooks/usePanGestureProxy.ts +144 -0
- package/src/hooks/usePropsErrorBoundary.ts +138 -0
- package/src/hooks/useSizeResolver.test.tsx +112 -0
- package/src/hooks/useSizeResolver.ts +106 -0
- package/src/hooks/useUpdateGestureConfig.test.ts +89 -0
- package/src/hooks/useUpdateGestureConfig.ts +14 -0
- package/src/hooks/useVisibleRanges.test.tsx +366 -0
- package/src/hooks/useVisibleRanges.tsx +123 -0
- package/src/index.tsx +13 -0
- package/src/layouts/index.tsx +12 -0
- package/src/layouts/normal.ts +32 -0
- package/src/layouts/parallax.test.ts +239 -0
- package/src/layouts/parallax.ts +83 -0
- package/src/layouts/stack.test.ts +252 -0
- package/src/layouts/stack.ts +306 -0
- package/src/store/index.test.tsx +314 -0
- package/src/store/index.tsx +66 -0
- package/src/types.ts +348 -0
- package/src/utils/compute-gesture-translation.test.ts +70 -0
- package/src/utils/compute-gesture-translation.ts +29 -0
- package/src/utils/compute-offset-if-data-changed.test.ts +133 -0
- package/src/utils/compute-offset-if-data-changed.ts +44 -0
- package/src/utils/compute-offset-if-size-changed.test.ts +78 -0
- package/src/utils/compute-offset-if-size-changed.ts +14 -0
- package/src/utils/compute-offset-if-sizes-changed.test.ts +74 -0
- package/src/utils/compute-offset-if-sizes-changed.ts +44 -0
- package/src/utils/computed-with-auto-fill-data.test.ts +298 -0
- package/src/utils/computed-with-auto-fill-data.ts +92 -0
- package/src/utils/deal-with-animation.test.ts +181 -0
- package/src/utils/deal-with-animation.ts +17 -0
- package/src/utils/handleroffset-direction.test.ts +124 -0
- package/src/utils/handleroffset-direction.ts +18 -0
- package/src/utils/index.test.ts +90 -0
- package/src/utils/log.test.ts +134 -0
- package/src/utils/log.ts +12 -0
- package/src/utils/sanitize-animation-style.test.ts +40 -0
- package/src/utils/sanitize-animation-style.ts +20 -0
- package/src/utils/size-resolver.test.ts +193 -0
- package/src/utils/size-resolver.ts +216 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { SharedValue } from "react-native-reanimated";
|
|
2
|
+
/**
|
|
3
|
+
* Worklet-safe abstraction over per-item sizes. Lets every position-math site
|
|
4
|
+
* read `offsetAt(i)` / `indexAt(offset)` instead of multiplying by a scalar
|
|
5
|
+
* `size`. Two implementations:
|
|
6
|
+
*
|
|
7
|
+
* - Uniform: backed by a single scalar; O(1) for every operation.
|
|
8
|
+
* - Variable: backed by a prefix-sum SharedValue<number[]>; O(log n) for
|
|
9
|
+
* `indexAt`, with a cached-hint fast path for sequential scrolls.
|
|
10
|
+
*/
|
|
11
|
+
export interface SizeResolver {
|
|
12
|
+
/**
|
|
13
|
+
* `true` when sizes vary per item (variable mode). UI-thread reads should be
|
|
14
|
+
* cheap — this flag lives outside SharedValues so worklets can branch on it.
|
|
15
|
+
*/
|
|
16
|
+
readonly variable: boolean;
|
|
17
|
+
/** Total span across all items: sum of every item's size. */
|
|
18
|
+
readonly total: SharedValue<number>;
|
|
19
|
+
/** Number of items (must equal `prefix.length - 1` in variable mode). */
|
|
20
|
+
readonly count: SharedValue<number>;
|
|
21
|
+
/** Size of item at `index`. Worklet-safe. */
|
|
22
|
+
itemSize: (index: number) => number;
|
|
23
|
+
/** Start offset of item at `index` (sum of sizes of items [0, index)). Worklet-safe. */
|
|
24
|
+
offsetAt: (index: number) => number;
|
|
25
|
+
/** Index of the item that contains pixel `offset` from the start. Worklet-safe. */
|
|
26
|
+
indexAt: (offset: number) => number;
|
|
27
|
+
/** Center offset of item at `index`: `offsetAt(index) + itemSize(index) / 2`. Worklet-safe. */
|
|
28
|
+
midpointOf: (index: number) => number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Binary search the prefix-sum array for the index `i` such that
|
|
32
|
+
* `prefix[i] <= target < prefix[i+1]`. Clamps to `[0, length-1]`.
|
|
33
|
+
*
|
|
34
|
+
* Worklet-callable. `prefix` should have `length === itemCount + 1` so that
|
|
35
|
+
* `prefix[itemCount]` equals the total span.
|
|
36
|
+
*/
|
|
37
|
+
export declare function binarySearchPrefix(prefix: number[], target: number): number;
|
|
38
|
+
/**
|
|
39
|
+
* Cached-hint variant: checks `hint`, `hint+1`, `hint-1` before falling back to
|
|
40
|
+
* full binary search. The common case during a single gesture is that the
|
|
41
|
+
* answer either stays the same or moves by ±1, so this keeps amortized cost at
|
|
42
|
+
* O(1) for typical scroll patterns.
|
|
43
|
+
*/
|
|
44
|
+
export declare function binarySearchPrefixCached(prefix: number[], target: number, hint: number): number;
|
|
45
|
+
/**
|
|
46
|
+
* Creates a resolver for the uniform-size case. The scalar `size` is read on
|
|
47
|
+
* every call so callers always get the latest value. The owner is responsible
|
|
48
|
+
* for keeping `total` in sync with `size * count` (typically via
|
|
49
|
+
* `useAnimatedReaction`).
|
|
50
|
+
*
|
|
51
|
+
* `size` may be `SharedValue<number | null>` — `null` is treated as 0, which
|
|
52
|
+
* lets callers pass `common.resolvedSize` directly without a cast.
|
|
53
|
+
*/
|
|
54
|
+
export declare function createUniformSizeResolver(opts: {
|
|
55
|
+
size: SharedValue<number | null> | SharedValue<number>;
|
|
56
|
+
count: SharedValue<number>;
|
|
57
|
+
total: SharedValue<number>;
|
|
58
|
+
}): SizeResolver;
|
|
59
|
+
/**
|
|
60
|
+
* Creates a resolver backed by a prefix-sum array. `prefix[i]` is the sum of
|
|
61
|
+
* sizes of items `[0, i)`, so `prefix[0] === 0` and `prefix[count] === total`.
|
|
62
|
+
* `sizes` is `[size(0), size(1), ..., size(count-1)]`.
|
|
63
|
+
*
|
|
64
|
+
* `hint` is an optional SharedValue used as the seed for `indexAt`'s cached
|
|
65
|
+
* binary search; passing the previous result keeps lookups O(1) during
|
|
66
|
+
* continuous scrolls.
|
|
67
|
+
*/
|
|
68
|
+
export declare function createVariableSizeResolver(opts: {
|
|
69
|
+
sizes: SharedValue<number[]>;
|
|
70
|
+
prefix: SharedValue<number[]>;
|
|
71
|
+
total: SharedValue<number>;
|
|
72
|
+
count: SharedValue<number>;
|
|
73
|
+
hint?: SharedValue<number>;
|
|
74
|
+
}): SizeResolver;
|
|
75
|
+
/**
|
|
76
|
+
* Builds a `(sizes, prefix, total)` tuple from a `getItemSize(index)` getter.
|
|
77
|
+
* JS-thread, O(n). Returns plain arrays — callers ferry them into SharedValues.
|
|
78
|
+
*
|
|
79
|
+
* Guards against non-finite or non-positive sizes by treating them as 0 so the
|
|
80
|
+
* carousel doesn't NaN-out. `usePropsErrorBoundary` warns the user separately.
|
|
81
|
+
*/
|
|
82
|
+
export declare function buildPrefixSum(count: number, getItemSize: (index: number) => number): {
|
|
83
|
+
sizes: number[];
|
|
84
|
+
prefix: number[];
|
|
85
|
+
total: number;
|
|
86
|
+
};
|
|
87
|
+
//# sourceMappingURL=size-resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"size-resolver.d.ts","sourceRoot":"","sources":["../../../src/utils/size-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D;;;;;;;;GAQG;AACH,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,6DAA6D;IAC7D,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACpC,yEAAyE;IACzE,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACpC,6CAA6C;IAC7C,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IACpC,wFAAwF;IACxF,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IACpC,mFAAmF;IACnF,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;IACpC,+FAA+F;IAC/F,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;CACvC;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAkB3E;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAe/F;AAED;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE;IAC9C,IAAI,EAAE,WAAW,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;IACvD,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC3B,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CAC5B,GAAG,YAAY,CAiCf;AAED;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE;IAC/C,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC;IAC7B,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC;IAC9B,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC3B,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC3B,IAAI,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CAC5B,GAAG,YAAY,CA8Cf;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,GACrC;IAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAatD"}
|
package/package.json
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@leonsilicon/react-native-reanimated-carousel",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"packageManager": "yarn@4.0.2",
|
|
5
|
+
"description": "Simple carousel component.fully implemented using Reanimated 2.Infinitely scrolling, very smooth.",
|
|
6
|
+
"author": "Doho <zhaodonghao586@outlook.com> (https://github.com/dohooo)",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"homepage": "https://rn-carousel.dev/",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/dohooo/react-native-reanimated-carousel.git"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/dohooo/react-native-reanimated-carousel/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"react-native",
|
|
18
|
+
"ios",
|
|
19
|
+
"android"
|
|
20
|
+
],
|
|
21
|
+
"main": "lib/commonjs/index",
|
|
22
|
+
"module": "lib/module/index",
|
|
23
|
+
"react-native": "src/index.tsx",
|
|
24
|
+
"types": "lib/typescript/index.d.ts",
|
|
25
|
+
"source": "src/index",
|
|
26
|
+
"files": [
|
|
27
|
+
"lib",
|
|
28
|
+
"src"
|
|
29
|
+
],
|
|
30
|
+
"scripts": {
|
|
31
|
+
"gif": "node scripts/makegif.js ./scripts/gif-works-directory",
|
|
32
|
+
"test": "jest",
|
|
33
|
+
"test:watch": "jest --watch",
|
|
34
|
+
"test:coverage": "jest --coverage",
|
|
35
|
+
"test:ci": "jest --coverage --ci --runInBand --reporters=default --reporters=jest-junit",
|
|
36
|
+
"types": "tsc --noEmit",
|
|
37
|
+
"lint": "biome check .",
|
|
38
|
+
"lint:fix": "biome check --write .",
|
|
39
|
+
"format": "biome format .",
|
|
40
|
+
"format:fix": "biome format --write .",
|
|
41
|
+
"dev": "watch 'yarn prepare' ./src",
|
|
42
|
+
"prepare": "bob build",
|
|
43
|
+
"clean": "del-cli lib",
|
|
44
|
+
"version": "changeset version",
|
|
45
|
+
"precommit": "yarn lint:fix && yarn format:fix",
|
|
46
|
+
"e2e": "APP_ID=${APP_ID:-com.react-native-reanimated-carousel.example} maestro test example/app/app/demos/",
|
|
47
|
+
"e2e:comprehensive": "APP_ID=${APP_ID:-com.react-native-reanimated-carousel.example} maestro test e2e/",
|
|
48
|
+
"changeset:check": "node scripts/check-changeset-style.mjs"
|
|
49
|
+
},
|
|
50
|
+
"resolutions": {
|
|
51
|
+
"@babel/plugin-transform-block-scoping": "7.28.4"
|
|
52
|
+
},
|
|
53
|
+
"publishConfig": {
|
|
54
|
+
"registry": "https://registry.npmjs.org/"
|
|
55
|
+
},
|
|
56
|
+
"peerDependencies": {
|
|
57
|
+
"react": ">=18.0.0",
|
|
58
|
+
"react-native": ">=0.80.0",
|
|
59
|
+
"react-native-gesture-handler": ">=2.9.0",
|
|
60
|
+
"react-native-reanimated": ">=4.0.0",
|
|
61
|
+
"react-native-worklets": ">=0.5.0"
|
|
62
|
+
},
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"@babel/core": "^7.28.4",
|
|
65
|
+
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
66
|
+
"@babel/plugin-proposal-private-methods": "^7.18.6",
|
|
67
|
+
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
68
|
+
"@babel/plugin-syntax-typescript": "^7.27.1",
|
|
69
|
+
"@babel/plugin-transform-block-scoping": "7.28.4",
|
|
70
|
+
"@babel/preset-typescript": "^7.27.1",
|
|
71
|
+
"@biomejs/biome": "^1.9.4",
|
|
72
|
+
"@changesets/changelog-github": "^0.5.0",
|
|
73
|
+
"@changesets/cli": "latest",
|
|
74
|
+
"@commitlint/config-conventional": "^11.0.0",
|
|
75
|
+
"@react-native/babel-preset": "0.81.1",
|
|
76
|
+
"@testing-library/jest-native": "^4.0.4",
|
|
77
|
+
"@testing-library/react-hooks": "^8.0.0",
|
|
78
|
+
"@testing-library/react-native": "^13.3.3",
|
|
79
|
+
"@types/jest": "^29.2.5",
|
|
80
|
+
"@types/react": "^19.1.10",
|
|
81
|
+
"@types/react-native": "^0.66.16",
|
|
82
|
+
"@types/react-test-renderer": "^19.1.0",
|
|
83
|
+
"babel-plugin-module-resolver": "^5.0.2",
|
|
84
|
+
"commitlint": "^11.0.0",
|
|
85
|
+
"cz-conventional-changelog": "^3.3.0",
|
|
86
|
+
"del-cli": "^5.0.0",
|
|
87
|
+
"gifify": "^2.4.3",
|
|
88
|
+
"husky": "^4.2.5",
|
|
89
|
+
"jest": "^29.3.1",
|
|
90
|
+
"jest-junit": "^16.0.0",
|
|
91
|
+
"pod-install": "^0.1.0",
|
|
92
|
+
"react": "19.1.0",
|
|
93
|
+
"react-dom": "19.1.0",
|
|
94
|
+
"react-native": "0.81.4",
|
|
95
|
+
"react-native-builder-bob": "0.39.1",
|
|
96
|
+
"react-native-gesture-handler": "~2.28.0",
|
|
97
|
+
"react-native-reanimated": "^4.1.0",
|
|
98
|
+
"react-native-web": "~0.19.10",
|
|
99
|
+
"react-native-worklets": "0.5.2",
|
|
100
|
+
"react-test-renderer": "19.1.0",
|
|
101
|
+
"sponsorkit": "^0.1.3",
|
|
102
|
+
"typescript": "^5.5.4",
|
|
103
|
+
"watch": "^1.0.2"
|
|
104
|
+
},
|
|
105
|
+
"husky": {
|
|
106
|
+
"hooks": {
|
|
107
|
+
"pre-commit": "yarn precommit",
|
|
108
|
+
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
"commitlint": {
|
|
112
|
+
"extends": [
|
|
113
|
+
"@commitlint/config-conventional"
|
|
114
|
+
],
|
|
115
|
+
"rules": {
|
|
116
|
+
"subject-case": [
|
|
117
|
+
0
|
|
118
|
+
],
|
|
119
|
+
"type-case": [
|
|
120
|
+
0
|
|
121
|
+
]
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
"react-native-builder-bob": {
|
|
125
|
+
"source": "src",
|
|
126
|
+
"output": "lib",
|
|
127
|
+
"targets": [
|
|
128
|
+
[
|
|
129
|
+
"commonjs",
|
|
130
|
+
{
|
|
131
|
+
"babelrc": false,
|
|
132
|
+
"configFile": "./babel.config.js"
|
|
133
|
+
}
|
|
134
|
+
],
|
|
135
|
+
[
|
|
136
|
+
"module",
|
|
137
|
+
{
|
|
138
|
+
"babelrc": false,
|
|
139
|
+
"configFile": "./babel.config.js"
|
|
140
|
+
}
|
|
141
|
+
],
|
|
142
|
+
"typescript"
|
|
143
|
+
],
|
|
144
|
+
"exclude": "**/*.test.{ts,tsx}"
|
|
145
|
+
},
|
|
146
|
+
"config": {
|
|
147
|
+
"commitizen": {
|
|
148
|
+
"path": "./node_modules/cz-conventional-changelog"
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|