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/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 { ILayoutConfig as IStackLayoutConfig } from './layouts/stack';
4
- import type { ILayoutConfig as IParallaxLayoutConfig } from './layouts/parallax';
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 TParallaxModeProps = ComputedDirectionTypes<{
39
- /**
40
- * Carousel Animated transitions.
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: (data: T, index: number) => React.ReactNode;
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;