react-native-reanimated-carousel 2.0.0 → 2.1.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/CHANGELOG.md +22 -0
- package/README.md +17 -8
- package/README.zh-CN.md +18 -8
- package/lib/commonjs/Carousel.js +11 -4
- package/lib/commonjs/Carousel.js.map +1 -1
- package/lib/commonjs/hooks/useInitProps.js.map +1 -1
- package/lib/commonjs/layouts/BaseLayout.js +14 -8
- package/lib/commonjs/layouts/BaseLayout.js.map +1 -1
- package/lib/commonjs/layouts/parallax.js.map +1 -1
- package/lib/commonjs/layouts/stack.js +15 -0
- package/lib/commonjs/layouts/stack.js.map +1 -1
- package/lib/module/Carousel.js +11 -4
- package/lib/module/Carousel.js.map +1 -1
- package/lib/module/hooks/useInitProps.js.map +1 -1
- package/lib/module/layouts/BaseLayout.js +14 -10
- package/lib/module/layouts/BaseLayout.js.map +1 -1
- package/lib/module/layouts/parallax.js.map +1 -1
- package/lib/module/layouts/stack.js +12 -0
- package/lib/module/layouts/stack.js.map +1 -1
- package/lib/typescript/layouts/BaseLayout.d.ts +3 -0
- package/lib/typescript/layouts/parallax.d.ts +9 -1
- package/lib/typescript/layouts/stack.d.ts +25 -0
- package/lib/typescript/types.d.ts +23 -28
- package/package.json +7 -3
- package/src/Carousel.tsx +17 -3
- package/src/hooks/useInitProps.ts +0 -1
- package/src/layouts/BaseLayout.tsx +26 -12
- package/src/layouts/parallax.ts +10 -1
- package/src/layouts/stack.ts +42 -0
- package/src/types.ts +27 -28
package/src/types.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { ViewStyle } from 'react-native';
|
|
2
2
|
import type { PanGestureHandlerProps } from 'react-native-gesture-handler';
|
|
3
|
-
import type
|
|
4
|
-
import type {
|
|
3
|
+
import type Animated from 'react-native-reanimated';
|
|
4
|
+
import type { TParallaxModeProps } from './layouts/parallax';
|
|
5
|
+
import type { TStackModeProps } from './layouts/stack';
|
|
5
6
|
|
|
6
7
|
export type ComputedDirectionTypes<T, VP = {}, HP = {}> =
|
|
7
8
|
| (T &
|
|
@@ -35,31 +36,10 @@ export type ComputedDirectionTypes<T, VP = {}, HP = {}> =
|
|
|
35
36
|
height?: number;
|
|
36
37
|
});
|
|
37
38
|
|
|
38
|
-
type
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
mode?: 'parallax';
|
|
43
|
-
modeConfig?: IParallaxLayoutConfig;
|
|
44
|
-
}>;
|
|
45
|
-
|
|
46
|
-
type TStackModeProps = ComputedDirectionTypes<{
|
|
47
|
-
/**
|
|
48
|
-
* Carousel Animated transitions.
|
|
49
|
-
*/
|
|
50
|
-
mode?: 'horizontal-stack' | 'vertical-stack';
|
|
51
|
-
/**
|
|
52
|
-
* Stack animation style.
|
|
53
|
-
* @default
|
|
54
|
-
* mode: 'vertical',
|
|
55
|
-
* snapDirection: 'right',
|
|
56
|
-
* moveSize: window.width,
|
|
57
|
-
* stackInterval: 30,
|
|
58
|
-
* scaleInterval: 0.08,
|
|
59
|
-
* rotateZDeg: 135,
|
|
60
|
-
*/
|
|
61
|
-
modeConfig?: IStackLayoutConfig;
|
|
62
|
-
}>;
|
|
39
|
+
export type CustomConfig = {
|
|
40
|
+
type?: 'negative' | 'positive';
|
|
41
|
+
viewCount?: number;
|
|
42
|
+
};
|
|
63
43
|
|
|
64
44
|
export type TCarouselProps<T = any> = {
|
|
65
45
|
ref?: React.Ref<ICarouselInstance>;
|
|
@@ -120,10 +100,19 @@ export type TCarouselProps<T = any> = {
|
|
|
120
100
|
* @default true
|
|
121
101
|
*/
|
|
122
102
|
enableSnap?: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Custom carousel config.
|
|
105
|
+
*/
|
|
106
|
+
customConfig?: () => CustomConfig;
|
|
107
|
+
/**
|
|
108
|
+
* Custom animations.
|
|
109
|
+
* Must use `worklet`, Details: https://docs.swmansion.com/react-native-reanimated/docs/2.2.0/worklets/
|
|
110
|
+
*/
|
|
111
|
+
customAnimation?: (value: number) => Animated.AnimatedStyleProp<ViewStyle>;
|
|
123
112
|
/**
|
|
124
113
|
* Render carousel item.
|
|
125
114
|
*/
|
|
126
|
-
renderItem:
|
|
115
|
+
renderItem: CarouselRenderItem<T>;
|
|
127
116
|
/**
|
|
128
117
|
* Callback fired when navigating to an item
|
|
129
118
|
*/
|
|
@@ -165,3 +154,13 @@ export interface ICarouselInstance {
|
|
|
165
154
|
*/
|
|
166
155
|
goToIndex: (index: number, animated?: boolean) => void;
|
|
167
156
|
}
|
|
157
|
+
|
|
158
|
+
export interface CarouselRenderItemInfo<ItemT> {
|
|
159
|
+
item: ItemT;
|
|
160
|
+
index: number;
|
|
161
|
+
animationValue: Animated.SharedValue<number>;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export type CarouselRenderItem<ItemT> = (
|
|
165
|
+
info: CarouselRenderItemInfo<ItemT>
|
|
166
|
+
) => React.ReactElement;
|