@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,123 @@
|
|
|
1
|
+
import { useRef } from "react";
|
|
2
|
+
import type { SharedValue } from "react-native-reanimated";
|
|
3
|
+
import { useDerivedValue } from "react-native-reanimated";
|
|
4
|
+
|
|
5
|
+
import type { SizeResolver } from "../utils/size-resolver";
|
|
6
|
+
|
|
7
|
+
type Range = [number, number];
|
|
8
|
+
|
|
9
|
+
export interface VisibleRanges {
|
|
10
|
+
negativeRange: Range;
|
|
11
|
+
positiveRange: Range;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type IVisibleRanges = SharedValue<VisibleRanges>;
|
|
15
|
+
|
|
16
|
+
export function useVisibleRanges(options: {
|
|
17
|
+
total: number;
|
|
18
|
+
viewSize: number;
|
|
19
|
+
windowSize?: number;
|
|
20
|
+
translation: SharedValue<number>;
|
|
21
|
+
loop?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Optional resolver. When supplied the hook locates `currentIndex` via
|
|
24
|
+
* `resolver.indexAt(-translation)` instead of `round(-translation / viewSize)`,
|
|
25
|
+
* which is what makes variable-size virtualization work without blanks.
|
|
26
|
+
*/
|
|
27
|
+
resolver?: SizeResolver;
|
|
28
|
+
}): IVisibleRanges {
|
|
29
|
+
const { total = 0, viewSize, translation, windowSize: _windowSize, loop, resolver } = options;
|
|
30
|
+
|
|
31
|
+
const windowSize =
|
|
32
|
+
typeof _windowSize === "number" && Number.isFinite(_windowSize) && _windowSize > 0
|
|
33
|
+
? _windowSize
|
|
34
|
+
: total;
|
|
35
|
+
const cachedRanges = useRef<VisibleRanges | null>(null);
|
|
36
|
+
|
|
37
|
+
const ranges = useDerivedValue(() => {
|
|
38
|
+
if (total <= 0) {
|
|
39
|
+
return {
|
|
40
|
+
negativeRange: [0, 0] as Range,
|
|
41
|
+
positiveRange: [0, -1] as Range,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// When a resolver is supplied, "ready" means the prefix table has been
|
|
46
|
+
// built (total > 0). Otherwise we need a positive viewSize to divide by.
|
|
47
|
+
const resolverReady = !!resolver?.variable && resolver.total.value > 0;
|
|
48
|
+
const uniformReady = Number.isFinite(viewSize) && viewSize > 0;
|
|
49
|
+
if (!resolverReady && !uniformReady) {
|
|
50
|
+
return {
|
|
51
|
+
negativeRange: [0, 0] as Range,
|
|
52
|
+
positiveRange: [0, Math.min(total - 1, windowSize - 1)] as Range,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const positiveCount = Math.round(windowSize / 2);
|
|
57
|
+
const negativeCount = windowSize - positiveCount;
|
|
58
|
+
|
|
59
|
+
let currentIndex = resolverReady
|
|
60
|
+
? resolver!.indexAt(-translation.value)
|
|
61
|
+
: Math.round(-translation.value / viewSize);
|
|
62
|
+
if (!Number.isFinite(currentIndex)) currentIndex = 0;
|
|
63
|
+
|
|
64
|
+
let newRanges: VisibleRanges;
|
|
65
|
+
|
|
66
|
+
if (!loop) {
|
|
67
|
+
// Clamp currentIndex to valid range [0, total-1] for non-loop mode
|
|
68
|
+
// When overdragging right, translation.value becomes positive, making currentIndex negative
|
|
69
|
+
currentIndex = Math.max(0, Math.min(total - 1, currentIndex));
|
|
70
|
+
|
|
71
|
+
// Adjusting negative range if the carousel is not loopable.
|
|
72
|
+
// So, It will be only displayed the positive items.
|
|
73
|
+
newRanges = {
|
|
74
|
+
negativeRange: [Math.max(0, currentIndex - (windowSize - 1)), currentIndex],
|
|
75
|
+
positiveRange: [currentIndex, Math.min(total - 1, currentIndex + (windowSize - 1))],
|
|
76
|
+
};
|
|
77
|
+
} else {
|
|
78
|
+
currentIndex = currentIndex < 0 ? (currentIndex % total) + total : currentIndex;
|
|
79
|
+
|
|
80
|
+
const negativeRange: Range = [
|
|
81
|
+
(currentIndex - negativeCount + total) % total,
|
|
82
|
+
(currentIndex - 1 + total) % total,
|
|
83
|
+
];
|
|
84
|
+
|
|
85
|
+
const positiveRange: Range = [
|
|
86
|
+
(currentIndex + total) % total,
|
|
87
|
+
(currentIndex + positiveCount + total) % total,
|
|
88
|
+
];
|
|
89
|
+
|
|
90
|
+
if (negativeRange[0] < total && negativeRange[0] > negativeRange[1]) {
|
|
91
|
+
negativeRange[1] = total - 1;
|
|
92
|
+
positiveRange[0] = 0;
|
|
93
|
+
}
|
|
94
|
+
if (positiveRange[0] > positiveRange[1]) {
|
|
95
|
+
negativeRange[1] = total - 1;
|
|
96
|
+
positiveRange[0] = 0;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// console.log({ negativeRange, positiveRange ,total,windowSize,a:total <= _windowSize})
|
|
100
|
+
newRanges = { negativeRange, positiveRange };
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (
|
|
104
|
+
cachedRanges.current &&
|
|
105
|
+
isArraysEqual(cachedRanges.current.negativeRange, newRanges.negativeRange) &&
|
|
106
|
+
isArraysEqual(cachedRanges.current.positiveRange, newRanges.positiveRange)
|
|
107
|
+
) {
|
|
108
|
+
return cachedRanges.current;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
cachedRanges.current = newRanges;
|
|
112
|
+
return newRanges;
|
|
113
|
+
}, [loop, total, windowSize, translation, viewSize, resolver]);
|
|
114
|
+
|
|
115
|
+
return ranges;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function isArraysEqual(a: number[], b: number[]): boolean {
|
|
119
|
+
"worklet";
|
|
120
|
+
if (a.length !== b.length) return false;
|
|
121
|
+
|
|
122
|
+
return a.every((value, index) => value === b[index]);
|
|
123
|
+
}
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import Carousel from "./components/Carousel";
|
|
2
|
+
export { Pagination } from "./components/Pagination";
|
|
3
|
+
|
|
4
|
+
export type {
|
|
5
|
+
TCarouselProps,
|
|
6
|
+
ICarouselInstance,
|
|
7
|
+
IComputedDirectionTypes,
|
|
8
|
+
CarouselRenderItem,
|
|
9
|
+
} from "./types";
|
|
10
|
+
export type { TAnimationStyle } from "./components/ItemLayout";
|
|
11
|
+
export type { ILayoutConfig } from "./layouts/stack";
|
|
12
|
+
|
|
13
|
+
export default Carousel;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { normalLayout } from "./normal";
|
|
2
|
+
import { parallaxLayout } from "./parallax";
|
|
3
|
+
import { horizontalStackLayout, verticalStackLayout } from "./stack";
|
|
4
|
+
|
|
5
|
+
export type TMode = "parallax" | "horizontal-stack" | "vertical-stack";
|
|
6
|
+
|
|
7
|
+
export const Layouts = {
|
|
8
|
+
normal: normalLayout,
|
|
9
|
+
parallax: parallaxLayout,
|
|
10
|
+
horizontalStack: horizontalStackLayout,
|
|
11
|
+
verticalStack: verticalStackLayout,
|
|
12
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { interpolate } from "react-native-reanimated";
|
|
2
|
+
|
|
3
|
+
import type { SizeResolver } from "../utils/size-resolver";
|
|
4
|
+
|
|
5
|
+
export function normalLayout(opts: {
|
|
6
|
+
size: number;
|
|
7
|
+
vertical: boolean;
|
|
8
|
+
/** When supplied, per-item translations use `resolver.itemSize(index)`. */
|
|
9
|
+
sizeResolver?: SizeResolver;
|
|
10
|
+
}) {
|
|
11
|
+
const { size, vertical, sizeResolver } = opts;
|
|
12
|
+
|
|
13
|
+
return (value: number, index: number) => {
|
|
14
|
+
"worklet";
|
|
15
|
+
// Use the per-item size in variable mode so non-uniform items keep their
|
|
16
|
+
// animation `value` semantics (-1 means one item-width to the left).
|
|
17
|
+
const itemSize = sizeResolver?.variable ? sizeResolver.itemSize(index) : size;
|
|
18
|
+
const translate = interpolate(value, [-1, 0, 1], [-itemSize, 0, itemSize]);
|
|
19
|
+
|
|
20
|
+
return {
|
|
21
|
+
transform: [
|
|
22
|
+
vertical
|
|
23
|
+
? {
|
|
24
|
+
translateY: translate,
|
|
25
|
+
}
|
|
26
|
+
: {
|
|
27
|
+
translateX: translate,
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
}
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { parallaxLayout } from "./parallax";
|
|
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
|
+
describe("parallaxLayout", () => {
|
|
25
|
+
const baseConfig = {
|
|
26
|
+
size: 300,
|
|
27
|
+
vertical: false,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
it("should create layout function with default config", () => {
|
|
31
|
+
const layout = parallaxLayout(baseConfig);
|
|
32
|
+
expect(typeof layout).toBe("function");
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("should return transform object for horizontal layout", () => {
|
|
36
|
+
const layout = parallaxLayout(baseConfig);
|
|
37
|
+
const result = layout(0);
|
|
38
|
+
|
|
39
|
+
expect(result).toHaveProperty("transform");
|
|
40
|
+
expect(result).toHaveProperty("zIndex");
|
|
41
|
+
expect(result.transform).toHaveLength(2);
|
|
42
|
+
expect(result.transform[0]).toHaveProperty("translateX");
|
|
43
|
+
expect(result.transform[1]).toHaveProperty("scale");
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("should return transform object for vertical layout", () => {
|
|
47
|
+
const verticalConfig = { ...baseConfig, vertical: true };
|
|
48
|
+
const layout = parallaxLayout(verticalConfig);
|
|
49
|
+
const result = layout(0);
|
|
50
|
+
|
|
51
|
+
expect(result).toHaveProperty("transform");
|
|
52
|
+
expect(result).toHaveProperty("zIndex");
|
|
53
|
+
expect(result.transform).toHaveLength(2);
|
|
54
|
+
expect(result.transform[0]).toHaveProperty("translateY");
|
|
55
|
+
expect(result.transform[1]).toHaveProperty("scale");
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it("should handle center position (value = 0)", () => {
|
|
59
|
+
const layout = parallaxLayout(baseConfig);
|
|
60
|
+
const result = layout(0);
|
|
61
|
+
|
|
62
|
+
// At center position, translateX should be 0
|
|
63
|
+
expect(result.transform[0].translateX).toBe(0);
|
|
64
|
+
// Scale should be a number (parallax logic applied)
|
|
65
|
+
expect(typeof result.transform[1].scale).toBe("number");
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it("should handle left position (value = -1)", () => {
|
|
69
|
+
const layout = parallaxLayout(baseConfig);
|
|
70
|
+
const result = layout(-1);
|
|
71
|
+
|
|
72
|
+
// At left position, translateX should be -size + parallaxScrollingOffset
|
|
73
|
+
expect(result.transform[0].translateX).toBe(-200); // -300 + 100
|
|
74
|
+
// Scale should be a number
|
|
75
|
+
expect(typeof result.transform[1].scale).toBe("number");
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("should handle right position (value = 1)", () => {
|
|
79
|
+
const layout = parallaxLayout(baseConfig);
|
|
80
|
+
const result = layout(1);
|
|
81
|
+
|
|
82
|
+
// At right position, translateX should be size - parallaxScrollingOffset
|
|
83
|
+
expect(result.transform[0].translateX).toBe(200); // 300 - 100
|
|
84
|
+
// Scale should be a number
|
|
85
|
+
expect(typeof result.transform[1].scale).toBe("number");
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it("should handle custom parallaxScrollingOffset", () => {
|
|
89
|
+
const modeConfig = { parallaxScrollingOffset: 50 };
|
|
90
|
+
const layout = parallaxLayout(baseConfig, modeConfig);
|
|
91
|
+
|
|
92
|
+
const leftResult = layout(-1);
|
|
93
|
+
const rightResult = layout(1);
|
|
94
|
+
|
|
95
|
+
expect(leftResult.transform[0].translateX).toBe(-250); // -300 + 50
|
|
96
|
+
expect(rightResult.transform[0].translateX).toBe(250); // 300 - 50
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it("should handle custom parallaxScrollingScale", () => {
|
|
100
|
+
const modeConfig = { parallaxScrollingScale: 0.9 };
|
|
101
|
+
const layout = parallaxLayout(baseConfig, modeConfig);
|
|
102
|
+
|
|
103
|
+
const centerResult = layout(0);
|
|
104
|
+
const sideResult = layout(-1);
|
|
105
|
+
|
|
106
|
+
// Verify the structure and that scale values are calculated
|
|
107
|
+
expect(typeof centerResult.transform[1].scale).toBe("number");
|
|
108
|
+
expect(typeof sideResult.transform[1].scale).toBe("number");
|
|
109
|
+
expect(centerResult.transform[1].scale).toBeGreaterThan(0);
|
|
110
|
+
expect(sideResult.transform[1].scale).toBeGreaterThan(0);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it("should handle custom parallaxAdjacentItemScale", () => {
|
|
114
|
+
const modeConfig = {
|
|
115
|
+
parallaxScrollingScale: 0.9,
|
|
116
|
+
parallaxAdjacentItemScale: 0.7,
|
|
117
|
+
};
|
|
118
|
+
const layout = parallaxLayout(baseConfig, modeConfig);
|
|
119
|
+
|
|
120
|
+
const centerResult = layout(0);
|
|
121
|
+
const sideResult = layout(-1);
|
|
122
|
+
|
|
123
|
+
// Verify the structure and that scale values are calculated
|
|
124
|
+
expect(typeof centerResult.transform[1].scale).toBe("number");
|
|
125
|
+
expect(typeof sideResult.transform[1].scale).toBe("number");
|
|
126
|
+
expect(centerResult.transform[1].scale).toBeGreaterThan(0);
|
|
127
|
+
expect(sideResult.transform[1].scale).toBeGreaterThan(0);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it("should handle vertical layout with custom config", () => {
|
|
131
|
+
const verticalConfig = { ...baseConfig, vertical: true };
|
|
132
|
+
const modeConfig = { parallaxScrollingOffset: 80 };
|
|
133
|
+
const layout = parallaxLayout(verticalConfig, modeConfig);
|
|
134
|
+
|
|
135
|
+
const leftResult = layout(-1);
|
|
136
|
+
const centerResult = layout(0);
|
|
137
|
+
const rightResult = layout(1);
|
|
138
|
+
|
|
139
|
+
expect(leftResult.transform[0].translateY).toBe(-220); // -300 + 80
|
|
140
|
+
expect(centerResult.transform[0].translateY).toBe(0);
|
|
141
|
+
expect(rightResult.transform[0].translateY).toBe(220); // 300 - 80
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it("should handle edge case values", () => {
|
|
145
|
+
const layout = parallaxLayout(baseConfig);
|
|
146
|
+
|
|
147
|
+
// Test with values beyond the normal range
|
|
148
|
+
const farLeftResult = layout(-2);
|
|
149
|
+
const farRightResult = layout(2);
|
|
150
|
+
|
|
151
|
+
expect(typeof farLeftResult.transform[0].translateX).toBe("number");
|
|
152
|
+
expect(typeof farLeftResult.transform[1].scale).toBe("number");
|
|
153
|
+
expect(typeof farRightResult.transform[0].translateX).toBe("number");
|
|
154
|
+
expect(typeof farRightResult.transform[1].scale).toBe("number");
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it("should handle fractional values", () => {
|
|
158
|
+
const layout = parallaxLayout(baseConfig);
|
|
159
|
+
|
|
160
|
+
const halfwayResult = layout(0.5);
|
|
161
|
+
const quarterResult = layout(-0.25);
|
|
162
|
+
|
|
163
|
+
expect(typeof halfwayResult.transform[0].translateX).toBe("number");
|
|
164
|
+
expect(typeof halfwayResult.transform[1].scale).toBe("number");
|
|
165
|
+
expect(typeof quarterResult.transform[0].translateX).toBe("number");
|
|
166
|
+
expect(typeof quarterResult.transform[1].scale).toBe("number");
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
it("should handle zero size", () => {
|
|
170
|
+
const zeroSizeConfig = { ...baseConfig, size: 0 };
|
|
171
|
+
const layout = parallaxLayout(zeroSizeConfig);
|
|
172
|
+
const result = layout(0);
|
|
173
|
+
|
|
174
|
+
expect(result).toHaveProperty("transform");
|
|
175
|
+
expect(result).toHaveProperty("zIndex");
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
it("should handle negative size", () => {
|
|
179
|
+
const negativeSizeConfig = { ...baseConfig, size: -100 };
|
|
180
|
+
const layout = parallaxLayout(negativeSizeConfig);
|
|
181
|
+
const result = layout(0);
|
|
182
|
+
|
|
183
|
+
expect(result).toHaveProperty("transform");
|
|
184
|
+
expect(result).toHaveProperty("zIndex");
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
it("should handle all config properties at once", () => {
|
|
188
|
+
const fullModeConfig = {
|
|
189
|
+
parallaxScrollingOffset: 75,
|
|
190
|
+
parallaxScrollingScale: 0.85,
|
|
191
|
+
parallaxAdjacentItemScale: 0.6,
|
|
192
|
+
};
|
|
193
|
+
const layout = parallaxLayout(baseConfig, fullModeConfig);
|
|
194
|
+
|
|
195
|
+
const centerResult = layout(0);
|
|
196
|
+
const sideResult = layout(-1);
|
|
197
|
+
|
|
198
|
+
// Verify the structure and that values are calculated correctly
|
|
199
|
+
expect(typeof centerResult.transform[1].scale).toBe("number");
|
|
200
|
+
expect(typeof sideResult.transform[1].scale).toBe("number");
|
|
201
|
+
expect(sideResult.transform[0].translateX).toBe(-225); // -300 + 75
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
it("should handle empty mode config", () => {
|
|
205
|
+
const layout = parallaxLayout(baseConfig, {});
|
|
206
|
+
const result = layout(0);
|
|
207
|
+
|
|
208
|
+
// At center (value = 0), scale should be a number (default parallax behavior)
|
|
209
|
+
expect(typeof result.transform[1].scale).toBe("number");
|
|
210
|
+
expect(result.transform[1].scale).toBeGreaterThan(0);
|
|
211
|
+
expect(result.transform[1].scale).toBeLessThanOrEqual(1);
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
it("should handle undefined mode config", () => {
|
|
215
|
+
const layout = parallaxLayout(baseConfig, undefined);
|
|
216
|
+
const result = layout(0);
|
|
217
|
+
|
|
218
|
+
// At center (value = 0), scale should be a number (default parallax behavior)
|
|
219
|
+
expect(typeof result.transform[1].scale).toBe("number");
|
|
220
|
+
expect(result.transform[1].scale).toBeGreaterThan(0);
|
|
221
|
+
expect(result.transform[1].scale).toBeLessThanOrEqual(1);
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
it("should maintain consistent zIndex calculation", () => {
|
|
225
|
+
const layout = parallaxLayout(baseConfig);
|
|
226
|
+
|
|
227
|
+
const leftResult = layout(-1);
|
|
228
|
+
const centerResult = layout(0);
|
|
229
|
+
const rightResult = layout(1);
|
|
230
|
+
|
|
231
|
+
expect(typeof leftResult.zIndex).toBe("number");
|
|
232
|
+
expect(typeof centerResult.zIndex).toBe("number");
|
|
233
|
+
expect(typeof rightResult.zIndex).toBe("number");
|
|
234
|
+
|
|
235
|
+
// Center should have highest zIndex
|
|
236
|
+
expect(centerResult.zIndex).toBeGreaterThanOrEqual(leftResult.zIndex);
|
|
237
|
+
expect(centerResult.zIndex).toBeGreaterThanOrEqual(rightResult.zIndex);
|
|
238
|
+
});
|
|
239
|
+
});
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { Extrapolation, interpolate } from "react-native-reanimated";
|
|
2
|
+
|
|
3
|
+
import type { IComputedDirectionTypes } from "../types";
|
|
4
|
+
import type { SizeResolver } from "../utils/size-resolver";
|
|
5
|
+
|
|
6
|
+
interface TBaseConfig {
|
|
7
|
+
size: number;
|
|
8
|
+
vertical: boolean;
|
|
9
|
+
/** When supplied, per-item translations and zIndex use the resolver. */
|
|
10
|
+
sizeResolver?: SizeResolver;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface ILayoutConfig {
|
|
14
|
+
/**
|
|
15
|
+
* control prev/next item offset.
|
|
16
|
+
* @default 100
|
|
17
|
+
*/
|
|
18
|
+
parallaxScrollingOffset?: number;
|
|
19
|
+
/**
|
|
20
|
+
* control prev/current/next item offset.
|
|
21
|
+
* @default 0.8
|
|
22
|
+
*/
|
|
23
|
+
parallaxScrollingScale?: number;
|
|
24
|
+
/**
|
|
25
|
+
* control prev/next item offset.
|
|
26
|
+
* @default Math.pow(parallaxScrollingScale, 2)
|
|
27
|
+
*/
|
|
28
|
+
parallaxAdjacentItemScale?: number;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export type TParallaxModeProps = IComputedDirectionTypes<{
|
|
32
|
+
/**
|
|
33
|
+
* Carousel Animated transitions.
|
|
34
|
+
*/
|
|
35
|
+
mode?: "parallax";
|
|
36
|
+
modeConfig?: ILayoutConfig;
|
|
37
|
+
}>;
|
|
38
|
+
|
|
39
|
+
export function parallaxLayout(baseConfig: TBaseConfig, modeConfig: ILayoutConfig = {}) {
|
|
40
|
+
const { size, vertical, sizeResolver } = baseConfig;
|
|
41
|
+
const {
|
|
42
|
+
parallaxScrollingOffset = 100,
|
|
43
|
+
parallaxScrollingScale = 0.8,
|
|
44
|
+
parallaxAdjacentItemScale = parallaxScrollingScale ** 2,
|
|
45
|
+
} = modeConfig;
|
|
46
|
+
|
|
47
|
+
return (value: number, index: number) => {
|
|
48
|
+
"worklet";
|
|
49
|
+
const itemSize = sizeResolver?.variable ? sizeResolver.itemSize(index) : size;
|
|
50
|
+
const translate = interpolate(
|
|
51
|
+
value,
|
|
52
|
+
[-1, 0, 1],
|
|
53
|
+
[-itemSize + parallaxScrollingOffset, 0, itemSize - parallaxScrollingOffset]
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
const zIndex = Math.round(
|
|
57
|
+
interpolate(value, [-1, 0, 1], [0, itemSize, 0], Extrapolation.CLAMP)
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
const scale = interpolate(
|
|
61
|
+
value,
|
|
62
|
+
[-1, 0, 1],
|
|
63
|
+
[parallaxAdjacentItemScale, parallaxScrollingScale, parallaxAdjacentItemScale],
|
|
64
|
+
Extrapolation.CLAMP
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
return {
|
|
68
|
+
transform: [
|
|
69
|
+
vertical
|
|
70
|
+
? {
|
|
71
|
+
translateY: translate,
|
|
72
|
+
}
|
|
73
|
+
: {
|
|
74
|
+
translateX: translate,
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
scale,
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
zIndex,
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
}
|