react-native-reanimated-carousel 3.1.0 → 3.1.2

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.
Files changed (166) hide show
  1. package/README.md +1 -0
  2. package/README.zh-CN.md +1 -0
  3. package/lib/commonjs/Carousel.js +1 -1
  4. package/lib/commonjs/Carousel.js.map +1 -1
  5. package/lib/commonjs/LazyView.js +1 -1
  6. package/lib/commonjs/LazyView.js.map +1 -1
  7. package/lib/commonjs/ScrollViewGesture.js +1 -1
  8. package/lib/commonjs/ScrollViewGesture.js.map +1 -1
  9. package/lib/commonjs/constants/index.js.map +1 -1
  10. package/lib/commonjs/hooks/computeNewIndexWhenDataChanges.js +2 -0
  11. package/lib/commonjs/hooks/computeNewIndexWhenDataChanges.js.map +1 -0
  12. package/lib/commonjs/hooks/index.test.js +2 -0
  13. package/lib/commonjs/hooks/index.test.js.map +1 -0
  14. package/lib/commonjs/hooks/useAutoPlay.js +1 -1
  15. package/lib/commonjs/hooks/useAutoPlay.js.map +1 -1
  16. package/lib/commonjs/hooks/useCarouselController.js +1 -1
  17. package/lib/commonjs/hooks/useCarouselController.js.map +1 -1
  18. package/lib/commonjs/hooks/useCheckMounted.js.map +1 -1
  19. package/lib/commonjs/hooks/useCommonVariables.js +1 -1
  20. package/lib/commonjs/hooks/useCommonVariables.js.map +1 -1
  21. package/lib/commonjs/hooks/useInitProps.js +1 -1
  22. package/lib/commonjs/hooks/useInitProps.js.map +1 -1
  23. package/lib/commonjs/hooks/useLayoutConfig.js +1 -1
  24. package/lib/commonjs/hooks/useLayoutConfig.js.map +1 -1
  25. package/lib/commonjs/hooks/useOffsetX.js +1 -1
  26. package/lib/commonjs/hooks/useOffsetX.js.map +1 -1
  27. package/lib/commonjs/hooks/useOnProgressChange.js +1 -1
  28. package/lib/commonjs/hooks/useOnProgressChange.js.map +1 -1
  29. package/lib/commonjs/hooks/usePropsErrorBoundary.js +1 -1
  30. package/lib/commonjs/hooks/usePropsErrorBoundary.js.map +1 -1
  31. package/lib/commonjs/hooks/useVisibleRanges.js +1 -1
  32. package/lib/commonjs/hooks/useVisibleRanges.js.map +1 -1
  33. package/lib/commonjs/index.js.map +1 -1
  34. package/lib/commonjs/layouts/BaseLayout.js +1 -1
  35. package/lib/commonjs/layouts/BaseLayout.js.map +1 -1
  36. package/lib/commonjs/layouts/ParallaxLayout.js +1 -1
  37. package/lib/commonjs/layouts/ParallaxLayout.js.map +1 -1
  38. package/lib/commonjs/layouts/index.js.map +1 -1
  39. package/lib/commonjs/layouts/normal.js +1 -1
  40. package/lib/commonjs/layouts/normal.js.map +1 -1
  41. package/lib/commonjs/layouts/parallax.js +1 -1
  42. package/lib/commonjs/layouts/parallax.js.map +1 -1
  43. package/lib/commonjs/layouts/stack.js +1 -1
  44. package/lib/commonjs/layouts/stack.js.map +1 -1
  45. package/lib/commonjs/store/index.js.map +1 -1
  46. package/lib/commonjs/utils/computedWithAutoFillData.js.map +1 -1
  47. package/lib/commonjs/utils/dealWithAnimation.js +1 -1
  48. package/lib/commonjs/utils/dealWithAnimation.js.map +1 -1
  49. package/lib/commonjs/utils/handlerOffsetDirection.js +2 -0
  50. package/lib/commonjs/utils/handlerOffsetDirection.js.map +1 -0
  51. package/lib/commonjs/utils/log.js +1 -1
  52. package/lib/commonjs/utils/log.js.map +1 -1
  53. package/lib/module/Carousel.js +24 -33
  54. package/lib/module/Carousel.js.map +1 -1
  55. package/lib/module/LazyView.js +2 -6
  56. package/lib/module/LazyView.js.map +1 -1
  57. package/lib/module/ScrollViewGesture.js +23 -39
  58. package/lib/module/ScrollViewGesture.js.map +1 -1
  59. package/lib/module/constants/index.js +1 -1
  60. package/lib/module/constants/index.js.map +1 -1
  61. package/lib/module/hooks/computeNewIndexWhenDataChanges.js +43 -0
  62. package/lib/module/hooks/computeNewIndexWhenDataChanges.js.map +1 -0
  63. package/lib/module/hooks/index.test.js +72 -0
  64. package/lib/module/hooks/index.test.js.map +1 -0
  65. package/lib/module/hooks/useAutoPlay.js +5 -19
  66. package/lib/module/hooks/useAutoPlay.js.map +1 -1
  67. package/lib/module/hooks/useCarouselController.js +24 -36
  68. package/lib/module/hooks/useCarouselController.js.map +1 -1
  69. package/lib/module/hooks/useCheckMounted.js +1 -1
  70. package/lib/module/hooks/useCheckMounted.js.map +1 -1
  71. package/lib/module/hooks/useCommonVariables.js +39 -3
  72. package/lib/module/hooks/useCommonVariables.js.map +1 -1
  73. package/lib/module/hooks/useInitProps.js +4 -7
  74. package/lib/module/hooks/useInitProps.js.map +1 -1
  75. package/lib/module/hooks/useLayoutConfig.js +5 -5
  76. package/lib/module/hooks/useLayoutConfig.js.map +1 -1
  77. package/lib/module/hooks/useOffsetX.js +5 -12
  78. package/lib/module/hooks/useOffsetX.js.map +1 -1
  79. package/lib/module/hooks/useOnProgressChange.js +4 -8
  80. package/lib/module/hooks/useOnProgressChange.js.map +1 -1
  81. package/lib/module/hooks/usePropsErrorBoundary.js +6 -6
  82. package/lib/module/hooks/usePropsErrorBoundary.js.map +1 -1
  83. package/lib/module/hooks/useVisibleRanges.js +1 -1
  84. package/lib/module/hooks/useVisibleRanges.js.map +1 -1
  85. package/lib/module/index.js +1 -1
  86. package/lib/module/index.js.map +1 -1
  87. package/lib/module/layouts/BaseLayout.js +15 -16
  88. package/lib/module/layouts/BaseLayout.js.map +1 -1
  89. package/lib/module/layouts/ParallaxLayout.js +9 -9
  90. package/lib/module/layouts/ParallaxLayout.js.map +1 -1
  91. package/lib/module/layouts/index.js +3 -3
  92. package/lib/module/layouts/index.js.map +1 -1
  93. package/lib/module/layouts/normal.js +2 -2
  94. package/lib/module/layouts/normal.js.map +1 -1
  95. package/lib/module/layouts/parallax.js +3 -3
  96. package/lib/module/layouts/parallax.js.map +1 -1
  97. package/lib/module/layouts/stack.js +20 -28
  98. package/lib/module/layouts/stack.js.map +1 -1
  99. package/lib/module/store/index.js +1 -1
  100. package/lib/module/store/index.js.map +1 -1
  101. package/lib/module/utils/computedWithAutoFillData.js +4 -4
  102. package/lib/module/utils/computedWithAutoFillData.js.map +1 -1
  103. package/lib/module/utils/dealWithAnimation.js +4 -4
  104. package/lib/module/utils/dealWithAnimation.js.map +1 -1
  105. package/lib/module/utils/handlerOffsetDirection.js +9 -0
  106. package/lib/module/utils/handlerOffsetDirection.js.map +1 -0
  107. package/lib/module/utils/log.js +2 -1
  108. package/lib/module/utils/log.js.map +1 -1
  109. package/lib/typescript/Carousel.d.ts +2 -2
  110. package/lib/typescript/LazyView.d.ts +1 -1
  111. package/lib/typescript/ScrollViewGesture.d.ts +3 -3
  112. package/lib/typescript/constants/index.d.ts +1 -1
  113. package/lib/typescript/hooks/computeNewIndexWhenDataChanges.d.ts +8 -0
  114. package/lib/typescript/hooks/index.test.d.ts +1 -0
  115. package/lib/typescript/hooks/useAutoPlay.d.ts +1 -1
  116. package/lib/typescript/hooks/useCarouselController.d.ts +5 -5
  117. package/lib/typescript/hooks/useCheckMounted.d.ts +1 -1
  118. package/lib/typescript/hooks/useCommonVariables.d.ts +2 -2
  119. package/lib/typescript/hooks/useInitProps.d.ts +2 -2
  120. package/lib/typescript/hooks/useLayoutConfig.d.ts +2 -2
  121. package/lib/typescript/hooks/useOffsetX.d.ts +3 -3
  122. package/lib/typescript/hooks/useOnProgressChange.d.ts +4 -4
  123. package/lib/typescript/hooks/usePropsErrorBoundary.d.ts +1 -1
  124. package/lib/typescript/hooks/useVisibleRanges.d.ts +1 -1
  125. package/lib/typescript/index.d.ts +2 -2
  126. package/lib/typescript/layouts/BaseLayout.d.ts +5 -4
  127. package/lib/typescript/layouts/ParallaxLayout.d.ts +5 -5
  128. package/lib/typescript/layouts/index.d.ts +4 -4
  129. package/lib/typescript/layouts/parallax.d.ts +15 -15
  130. package/lib/typescript/layouts/stack.d.ts +15 -15
  131. package/lib/typescript/store/index.d.ts +2 -2
  132. package/lib/typescript/types.d.ts +112 -112
  133. package/lib/typescript/utils/dealWithAnimation.d.ts +1 -1
  134. package/lib/typescript/utils/handlerOffsetDirection.d.ts +2 -0
  135. package/package.json +9 -5
  136. package/src/Carousel.tsx +228 -229
  137. package/src/LazyView.tsx +6 -7
  138. package/src/ScrollViewGesture.tsx +251 -257
  139. package/src/constants/index.ts +10 -9
  140. package/src/hooks/computeNewIndexWhenDataChanges.ts +51 -0
  141. package/src/hooks/index.test.ts +82 -0
  142. package/src/hooks/useAutoPlay.ts +59 -59
  143. package/src/hooks/useCarouselController.tsx +296 -299
  144. package/src/hooks/useCheckMounted.ts +9 -9
  145. package/src/hooks/useCommonVariables.ts +64 -27
  146. package/src/hooks/useInitProps.ts +71 -70
  147. package/src/hooks/useLayoutConfig.ts +21 -19
  148. package/src/hooks/useOffsetX.ts +71 -71
  149. package/src/hooks/useOnProgressChange.ts +48 -47
  150. package/src/hooks/usePropsErrorBoundary.ts +27 -26
  151. package/src/hooks/useVisibleRanges.tsx +39 -39
  152. package/src/index.tsx +5 -5
  153. package/src/layouts/BaseLayout.tsx +103 -101
  154. package/src/layouts/ParallaxLayout.tsx +126 -124
  155. package/src/layouts/index.tsx +8 -8
  156. package/src/layouts/normal.ts +16 -16
  157. package/src/layouts/parallax.ts +62 -61
  158. package/src/layouts/stack.ts +320 -315
  159. package/src/store/index.ts +8 -7
  160. package/src/types.ts +111 -110
  161. package/src/utils/computedWithAutoFillData.ts +60 -60
  162. package/src/utils/dealWithAnimation.ts +19 -18
  163. package/src/utils/handlerOffsetDirection.ts +15 -0
  164. package/src/utils/log.ts +4 -3
  165. package/CHANGELOG.md +0 -610
  166. package/src/.DS_Store +0 -0
@@ -1,30 +1,30 @@
1
- import type { IComputedDirectionTypes } from '../types';
2
- declare type TBaseConfig = {
1
+ import type { IComputedDirectionTypes } from "../types";
2
+ interface TBaseConfig {
3
3
  size: number;
4
4
  vertical: boolean;
5
- };
5
+ }
6
6
  export interface ILayoutConfig {
7
7
  /**
8
- * control prev/next item offset.
9
- * @default 100
10
- */
8
+ * control prev/next item offset.
9
+ * @default 100
10
+ */
11
11
  parallaxScrollingOffset?: number;
12
12
  /**
13
- * control prev/current/next item offset.
14
- * @default 0.8
15
- */
13
+ * control prev/current/next item offset.
14
+ * @default 0.8
15
+ */
16
16
  parallaxScrollingScale?: number;
17
17
  /**
18
- * control prev/next item offset.
19
- * @default Math.pow(parallaxScrollingScale, 2)
20
- */
18
+ * control prev/next item offset.
19
+ * @default Math.pow(parallaxScrollingScale, 2)
20
+ */
21
21
  parallaxAdjacentItemScale?: number;
22
22
  }
23
23
  export declare type TParallaxModeProps = IComputedDirectionTypes<{
24
24
  /**
25
- * Carousel Animated transitions.
26
- */
27
- mode?: 'parallax';
25
+ * Carousel Animated transitions.
26
+ */
27
+ mode?: "parallax";
28
28
  modeConfig?: ILayoutConfig;
29
29
  }>;
30
30
  export declare function parallaxLayout(baseConfig: TBaseConfig, modeConfig?: ILayoutConfig): (value: number) => {
@@ -1,5 +1,5 @@
1
- import { ViewStyle } from 'react-native';
2
- import type { IComputedDirectionTypes, CustomConfig } from '../types';
1
+ import type { ViewStyle } from "react-native";
2
+ import type { IComputedDirectionTypes, CustomConfig } from "../types";
3
3
  export interface ILayoutConfig {
4
4
  showLength?: number;
5
5
  moveSize?: number;
@@ -7,23 +7,23 @@ export interface ILayoutConfig {
7
7
  scaleInterval?: number;
8
8
  opacityInterval?: number;
9
9
  rotateZDeg?: number;
10
- snapDirection?: 'left' | 'right';
10
+ snapDirection?: "left" | "right";
11
11
  }
12
12
  export declare type TStackModeProps = IComputedDirectionTypes<{
13
13
  /**
14
- * Carousel Animated transitions.
15
- */
16
- mode?: 'horizontal-stack' | 'vertical-stack';
14
+ * Carousel Animated transitions.
15
+ */
16
+ mode?: "horizontal-stack" | "vertical-stack";
17
17
  /**
18
- * Stack animation style.
19
- * @default
20
- * mode: 'vertical',
21
- * snapDirection: 'right',
22
- * moveSize: window.width,
23
- * stackInterval: 30,
24
- * scaleInterval: 0.08,
25
- * rotateZDeg: 135,
26
- */
18
+ * Stack animation style.
19
+ * @default
20
+ * mode: 'vertical',
21
+ * snapDirection: 'right',
22
+ * moveSize: window.width,
23
+ * stackInterval: 30,
24
+ * scaleInterval: 0.08,
25
+ * rotateZDeg: 135,
26
+ */
27
27
  modeConfig?: ILayoutConfig;
28
28
  }>;
29
29
  export declare function horizontalStackLayout(modeConfig?: ILayoutConfig): (_value: number) => ViewStyle;
@@ -1,5 +1,5 @@
1
- import React from 'react';
2
- import type { TInitializeCarouselProps } from '../hooks/useInitProps';
1
+ import React from "react";
2
+ import type { TInitializeCarouselProps } from "../hooks/useInitProps";
3
3
  export interface IContext {
4
4
  props: TInitializeCarouselProps<any>;
5
5
  common: {
@@ -1,193 +1,193 @@
1
1
  /// <reference types="react" />
2
- import type { StyleProp, ViewStyle } from 'react-native';
3
- import type { PanGestureHandlerProps } from 'react-native-gesture-handler';
4
- import type { AnimatedStyleProp, SharedValue, WithSpringConfig, WithTimingConfig } from 'react-native-reanimated';
5
- import type Animated from 'react-native-reanimated';
6
- import type { TParallaxModeProps } from './layouts/parallax';
7
- import type { TStackModeProps } from './layouts/stack';
2
+ import type { StyleProp, ViewStyle } from "react-native";
3
+ import type { PanGestureHandlerProps } from "react-native-gesture-handler";
4
+ import type { AnimatedStyleProp, SharedValue, WithSpringConfig, WithTimingConfig } from "react-native-reanimated";
5
+ import type Animated from "react-native-reanimated";
6
+ import type { TParallaxModeProps } from "./layouts/parallax";
7
+ import type { TStackModeProps } from "./layouts/stack";
8
8
  export declare type IComputedDirectionTypes<T, VP = {}, HP = {}> = (T & VP & {
9
9
  /**
10
- * Layout items vertically instead of horizontally
11
- */
10
+ * Layout items vertically instead of horizontally
11
+ */
12
12
  vertical: true;
13
13
  /**
14
- * Layout items vertically instead of horizontally
15
- */
14
+ * Layout items vertically instead of horizontally
15
+ */
16
16
  /**
17
- * Specified carousel container width.
18
- */
17
+ * Specified carousel container width.
18
+ */
19
19
  width?: number;
20
20
  height: number;
21
21
  }) | (T & HP & {
22
22
  /**
23
- * Layout items vertically instead of horizontally
24
- */
23
+ * Layout items vertically instead of horizontally
24
+ */
25
25
  vertical?: false;
26
26
  /**
27
- * Layout items vertically instead of horizontally
28
- */
27
+ * Layout items vertically instead of horizontally
28
+ */
29
29
  /**
30
- * Specified carousel container width.
31
- */
30
+ * Specified carousel container width.
31
+ */
32
32
  width: number;
33
33
  height?: number;
34
34
  });
35
- export declare type CustomConfig = {
36
- type?: 'negative' | 'positive';
35
+ export interface CustomConfig {
36
+ type?: "negative" | "positive";
37
37
  viewCount?: number;
38
- };
39
- export declare type WithSpringAnimation = {
40
- type: 'spring';
38
+ }
39
+ export interface WithSpringAnimation {
40
+ type: "spring";
41
41
  config: WithSpringConfig;
42
- };
43
- export declare type WithTimingAnimation = {
44
- type: 'timing';
42
+ }
43
+ export interface WithTimingAnimation {
44
+ type: "timing";
45
45
  config: WithTimingConfig;
46
- };
46
+ }
47
47
  export declare type WithAnimation = WithSpringAnimation | WithTimingAnimation;
48
48
  export declare type TCarouselProps<T = any> = {
49
49
  ref?: React.Ref<ICarouselInstance>;
50
50
  /**
51
- * The default animated value of the carousel.
52
- */
51
+ * The default animated value of the carousel.
52
+ */
53
53
  defaultScrollOffsetValue?: SharedValue<number>;
54
54
  /**
55
- * Carousel loop playback.
56
- * @default true
57
- */
55
+ * Carousel loop playback.
56
+ * @default true
57
+ */
58
58
  loop?: boolean;
59
59
  /**
60
- * Carousel items data set.
61
- */
60
+ * Carousel items data set.
61
+ */
62
62
  data: T[];
63
63
  /**
64
- * Auto fill data array to allow loop playback when the loop props is true.
65
- * @default true
66
- * @example
67
- * [1] => [1, 1, 1]
68
- * [1, 2] => [1, 2, 1, 2]
69
- */
64
+ * Auto fill data array to allow loop playback when the loop props is true.
65
+ * @default true
66
+ * @example
67
+ * [1] => [1, 1, 1]
68
+ * [1, 2] => [1, 2, 1, 2]
69
+ */
70
70
  autoFillData?: boolean;
71
71
  /**
72
- * Default index
73
- * @default 0
74
- */
72
+ * Default index
73
+ * @default 0
74
+ */
75
75
  defaultIndex?: number;
76
76
  /**
77
- * Auto play
78
- */
77
+ * Auto play
78
+ */
79
79
  autoPlay?: boolean;
80
80
  /**
81
- * Auto play
82
- * @description reverse playback
83
- */
81
+ * Auto play
82
+ * @description reverse playback
83
+ */
84
84
  autoPlayReverse?: boolean;
85
85
  /**
86
- * Auto play
87
- * @description playback interval
88
- */
86
+ * Auto play
87
+ * @description playback interval
88
+ */
89
89
  autoPlayInterval?: number;
90
90
  /**
91
- * Time a scroll animation takes to finish
92
- * @default 500 (ms)
93
- */
91
+ * Time a scroll animation takes to finish
92
+ * @default 500 (ms)
93
+ */
94
94
  scrollAnimationDuration?: number;
95
95
  /**
96
- * Carousel container style
97
- */
96
+ * Carousel container style
97
+ */
98
98
  style?: StyleProp<ViewStyle>;
99
99
  /**
100
- * PanGestureHandler props
101
- */
102
- panGestureHandlerProps?: Partial<Omit<PanGestureHandlerProps, 'onHandlerStateChange' | 'enabled'>>;
100
+ * PanGestureHandler props
101
+ */
102
+ panGestureHandlerProps?: Partial<Omit<PanGestureHandlerProps, "onHandlerStateChange" | "enabled">>;
103
103
  /**
104
- * Determines the maximum number of items will respond to pan gesture events,
105
- * windowSize={11} will active visible item plus up to 5 items above and 5 below the viewpor,
106
- * Reducing this number will reduce the calculation of the animation value and may improve performance.
107
- * @default 0 all items will respond to pan gesture events.
108
- */
104
+ * Determines the maximum number of items will respond to pan gesture events,
105
+ * windowSize={11} will active visible item plus up to 5 items above and 5 below the viewpor,
106
+ * Reducing this number will reduce the calculation of the animation value and may improve performance.
107
+ * @default 0 all items will respond to pan gesture events.
108
+ */
109
109
  windowSize?: number;
110
110
  /**
111
- * When true, the scroll view stops on multiples of the scroll view's size when scrolling.
112
- * @default true
113
- */
111
+ * When true, the scroll view stops on multiples of the scroll view's size when scrolling.
112
+ * @default true
113
+ */
114
114
  pagingEnabled?: boolean;
115
115
  /**
116
- * If enabled, releasing the touch will scroll to the nearest item.
117
- * valid when pagingEnabled=false
118
- * @deprecated please use snapEnabled instead
119
- */
116
+ * If enabled, releasing the touch will scroll to the nearest item.
117
+ * valid when pagingEnabled=false
118
+ * @deprecated please use snapEnabled instead
119
+ */
120
120
  enableSnap?: boolean;
121
121
  /**
122
- * If enabled, releasing the touch will scroll to the nearest item.
123
- * valid when pagingEnabled=false
124
- * @default true
125
- */
122
+ * If enabled, releasing the touch will scroll to the nearest item.
123
+ * valid when pagingEnabled=false
124
+ * @default true
125
+ */
126
126
  snapEnabled?: boolean;
127
127
  /**
128
- * If false, Carousel will not respond to any gestures.
129
- * @default true
130
- */
128
+ * If false, Carousel will not respond to any gestures.
129
+ * @default true
130
+ */
131
131
  enabled?: boolean;
132
132
  /**
133
- * Specifies the scrolling animation effect.
134
- */
133
+ * Specifies the scrolling animation effect.
134
+ */
135
135
  withAnimation?: WithAnimation;
136
136
  /**
137
- * Used to locate this view in end-to-end tests.
138
- */
137
+ * Used to locate this view in end-to-end tests.
138
+ */
139
139
  testID?: string;
140
140
  /**
141
- * Custom carousel config.
142
- */
141
+ * Custom carousel config.
142
+ */
143
143
  customConfig?: () => CustomConfig;
144
144
  /**
145
- * Custom animations.
146
- * Must use `worklet`, Details: https://docs.swmansion.com/react-native-reanimated/docs/2.2.0/worklets/
147
- */
145
+ * Custom animations.
146
+ * Must use `worklet`, Details: https://docs.swmansion.com/react-native-reanimated/docs/2.2.0/worklets/
147
+ */
148
148
  customAnimation?: (value: number) => AnimatedStyleProp<ViewStyle>;
149
149
  /**
150
- * Render carousel item.
151
- */
150
+ * Render carousel item.
151
+ */
152
152
  renderItem: CarouselRenderItem<T>;
153
153
  /**
154
- * Callback fired when navigating to an item.
155
- */
154
+ * Callback fired when navigating to an item.
155
+ */
156
156
  onSnapToItem?: (index: number) => void;
157
157
  /**
158
- * On scroll begin
159
- */
158
+ * On scroll begin
159
+ */
160
160
  onScrollBegin?: () => void;
161
161
  /**
162
- * On scroll end
163
- */
162
+ * On scroll end
163
+ */
164
164
  onScrollEnd?: (index: number) => void;
165
165
  /**
166
- * On progress change
167
- * @param offsetProgress Total of offset distance (0 390 780 ...)
168
- * @param absoluteProgress Convert to index (0 1 2 ...)
169
- */
166
+ * On progress change
167
+ * @param offsetProgress Total of offset distance (0 390 780 ...)
168
+ * @param absoluteProgress Convert to index (0 1 2 ...)
169
+ */
170
170
  onProgressChange?: (offsetProgress: number, absoluteProgress: number) => void;
171
171
  } & (TParallaxModeProps | TStackModeProps);
172
172
  export interface ICarouselInstance {
173
173
  /**
174
- * Scroll to previous item, it takes one optional argument (count),
175
- * which allows you to specify how many items to cross
176
- */
177
- prev: (opts?: Omit<TCarouselActionOptions, 'index'>) => void;
174
+ * Scroll to previous item, it takes one optional argument (count),
175
+ * which allows you to specify how many items to cross
176
+ */
177
+ prev: (opts?: Omit<TCarouselActionOptions, "index">) => void;
178
178
  /**
179
- * Scroll to next item, it takes one optional argument (count),
180
- * which allows you to specify how many items to cross
181
- */
182
- next: (opts?: Omit<TCarouselActionOptions, 'index'>) => void;
179
+ * Scroll to next item, it takes one optional argument (count),
180
+ * which allows you to specify how many items to cross
181
+ */
182
+ next: (opts?: Omit<TCarouselActionOptions, "index">) => void;
183
183
  /**
184
- * Get current item index
185
- */
184
+ * Get current item index
185
+ */
186
186
  getCurrentIndex: () => number;
187
187
  /**
188
- * Use value to scroll to a position where relative to the current position,
189
- * scrollTo(-2) is equivalent to prev(2), scrollTo(2) is equivalent to next(2)
190
- */
188
+ * Use value to scroll to a position where relative to the current position,
189
+ * scrollTo(-2) is equivalent to prev(2), scrollTo(2) is equivalent to next(2)
190
+ */
191
191
  scrollTo: (opts?: TCarouselActionOptions) => void;
192
192
  }
193
193
  export interface CarouselRenderItemInfo<ItemT> {
@@ -1,2 +1,2 @@
1
- import type { WithAnimation } from '../types';
1
+ import type { WithAnimation } from "../types";
2
2
  export declare function dealWithAnimation(withAnimation: WithAnimation): (value: number, cb: (isFinished: boolean) => void) => number;
@@ -0,0 +1,2 @@
1
+ import type { SharedValue } from "react-native-reanimated";
2
+ export declare function handlerOffsetDirection(handlerOffset: SharedValue<number>): -1 | 1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-reanimated-carousel",
3
- "version": "3.1.0",
3
+ "version": "3.1.2",
4
4
  "description": "Simple carousel component.fully implemented using Reanimated 2.Infinitely scrolling, very smooth.",
5
5
  "main": "lib/commonjs/index",
6
6
  "react-native": "src/index.tsx",
@@ -22,9 +22,11 @@
22
22
  ],
23
23
  "scripts": {
24
24
  "gif": "node scripts/makegif.js ./scripts/gif-works-directory",
25
- "test": "jest",
25
+ "test": "vitest run src/**/*",
26
+ "test:dev": "vitest dev src/**/*",
26
27
  "typescript": "tsc --noEmit",
27
28
  "lint": "eslint \"src/**/*.{js,ts,tsx}\"",
29
+ "lint:fix": "eslint \"src/**/*.{js,ts,tsx}\" --fix",
28
30
  "dev": "yarn watch 'yarn prepare' ./src",
29
31
  "prepare": "bob build",
30
32
  "release": "yarn prepare && dotenv release-it --no-git.requireUpstream",
@@ -57,6 +59,7 @@
57
59
  "devDependencies": {
58
60
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
59
61
  "@commitlint/config-conventional": "^11.0.0",
62
+ "@dohooo/eslint-config": "^0.0.7",
60
63
  "@react-native-community/eslint-config": "^2.0.0",
61
64
  "@release-it/conventional-changelog": "^2.0.0",
62
65
  "@types/jest": "^26.0.0",
@@ -68,7 +71,7 @@
68
71
  "commitlint": "^11.0.0",
69
72
  "cz-conventional-changelog": "^3.3.0",
70
73
  "dotenv-cli": "^5.1.0",
71
- "eslint": "^7.2.0",
74
+ "eslint": "^8.26.0",
72
75
  "eslint-config-prettier": "^7.0.0",
73
76
  "eslint-plugin-prettier": "^3.1.3",
74
77
  "gifify": "^2.4.3",
@@ -83,7 +86,8 @@
83
86
  "react-native-reanimated": "2.8.0",
84
87
  "release-it": "^14.2.2",
85
88
  "sponsorkit": "^0.1.3",
86
- "typescript": "^4.0.8"
89
+ "typescript": "^4.0.8",
90
+ "vitest": "^0.24.3"
87
91
  },
88
92
  "peerDependencies": {
89
93
  "react": ">=16.8.0",
@@ -102,7 +106,7 @@
102
106
  "husky": {
103
107
  "hooks": {
104
108
  "commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
105
- "pre-commit": "yarn lint && yarn typescript"
109
+ "pre-commit": "yarn test && yarn lint && yarn typescript"
106
110
  }
107
111
  },
108
112
  "commitlint": {