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.
- package/README.md +1 -0
- package/README.zh-CN.md +1 -0
- package/lib/commonjs/Carousel.js +1 -1
- package/lib/commonjs/Carousel.js.map +1 -1
- package/lib/commonjs/LazyView.js +1 -1
- package/lib/commonjs/LazyView.js.map +1 -1
- package/lib/commonjs/ScrollViewGesture.js +1 -1
- package/lib/commonjs/ScrollViewGesture.js.map +1 -1
- package/lib/commonjs/constants/index.js.map +1 -1
- package/lib/commonjs/hooks/computeNewIndexWhenDataChanges.js +2 -0
- package/lib/commonjs/hooks/computeNewIndexWhenDataChanges.js.map +1 -0
- package/lib/commonjs/hooks/index.test.js +2 -0
- package/lib/commonjs/hooks/index.test.js.map +1 -0
- package/lib/commonjs/hooks/useAutoPlay.js +1 -1
- package/lib/commonjs/hooks/useAutoPlay.js.map +1 -1
- package/lib/commonjs/hooks/useCarouselController.js +1 -1
- package/lib/commonjs/hooks/useCarouselController.js.map +1 -1
- package/lib/commonjs/hooks/useCheckMounted.js.map +1 -1
- package/lib/commonjs/hooks/useCommonVariables.js +1 -1
- package/lib/commonjs/hooks/useCommonVariables.js.map +1 -1
- package/lib/commonjs/hooks/useInitProps.js +1 -1
- package/lib/commonjs/hooks/useInitProps.js.map +1 -1
- package/lib/commonjs/hooks/useLayoutConfig.js +1 -1
- package/lib/commonjs/hooks/useLayoutConfig.js.map +1 -1
- package/lib/commonjs/hooks/useOffsetX.js +1 -1
- package/lib/commonjs/hooks/useOffsetX.js.map +1 -1
- package/lib/commonjs/hooks/useOnProgressChange.js +1 -1
- package/lib/commonjs/hooks/useOnProgressChange.js.map +1 -1
- package/lib/commonjs/hooks/usePropsErrorBoundary.js +1 -1
- package/lib/commonjs/hooks/usePropsErrorBoundary.js.map +1 -1
- package/lib/commonjs/hooks/useVisibleRanges.js +1 -1
- package/lib/commonjs/hooks/useVisibleRanges.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/layouts/BaseLayout.js +1 -1
- package/lib/commonjs/layouts/BaseLayout.js.map +1 -1
- package/lib/commonjs/layouts/ParallaxLayout.js +1 -1
- package/lib/commonjs/layouts/ParallaxLayout.js.map +1 -1
- package/lib/commonjs/layouts/index.js.map +1 -1
- package/lib/commonjs/layouts/normal.js +1 -1
- package/lib/commonjs/layouts/normal.js.map +1 -1
- package/lib/commonjs/layouts/parallax.js +1 -1
- package/lib/commonjs/layouts/parallax.js.map +1 -1
- package/lib/commonjs/layouts/stack.js +1 -1
- package/lib/commonjs/layouts/stack.js.map +1 -1
- package/lib/commonjs/store/index.js.map +1 -1
- package/lib/commonjs/utils/computedWithAutoFillData.js.map +1 -1
- package/lib/commonjs/utils/dealWithAnimation.js +1 -1
- package/lib/commonjs/utils/dealWithAnimation.js.map +1 -1
- package/lib/commonjs/utils/handlerOffsetDirection.js +2 -0
- package/lib/commonjs/utils/handlerOffsetDirection.js.map +1 -0
- package/lib/commonjs/utils/log.js +1 -1
- package/lib/commonjs/utils/log.js.map +1 -1
- package/lib/module/Carousel.js +24 -33
- package/lib/module/Carousel.js.map +1 -1
- package/lib/module/LazyView.js +2 -6
- package/lib/module/LazyView.js.map +1 -1
- package/lib/module/ScrollViewGesture.js +23 -39
- package/lib/module/ScrollViewGesture.js.map +1 -1
- package/lib/module/constants/index.js +1 -1
- package/lib/module/constants/index.js.map +1 -1
- package/lib/module/hooks/computeNewIndexWhenDataChanges.js +43 -0
- package/lib/module/hooks/computeNewIndexWhenDataChanges.js.map +1 -0
- package/lib/module/hooks/index.test.js +72 -0
- package/lib/module/hooks/index.test.js.map +1 -0
- package/lib/module/hooks/useAutoPlay.js +5 -19
- package/lib/module/hooks/useAutoPlay.js.map +1 -1
- package/lib/module/hooks/useCarouselController.js +24 -36
- package/lib/module/hooks/useCarouselController.js.map +1 -1
- package/lib/module/hooks/useCheckMounted.js +1 -1
- package/lib/module/hooks/useCheckMounted.js.map +1 -1
- package/lib/module/hooks/useCommonVariables.js +39 -3
- package/lib/module/hooks/useCommonVariables.js.map +1 -1
- package/lib/module/hooks/useInitProps.js +4 -7
- package/lib/module/hooks/useInitProps.js.map +1 -1
- package/lib/module/hooks/useLayoutConfig.js +5 -5
- package/lib/module/hooks/useLayoutConfig.js.map +1 -1
- package/lib/module/hooks/useOffsetX.js +5 -12
- package/lib/module/hooks/useOffsetX.js.map +1 -1
- package/lib/module/hooks/useOnProgressChange.js +4 -8
- package/lib/module/hooks/useOnProgressChange.js.map +1 -1
- package/lib/module/hooks/usePropsErrorBoundary.js +6 -6
- package/lib/module/hooks/usePropsErrorBoundary.js.map +1 -1
- package/lib/module/hooks/useVisibleRanges.js +1 -1
- package/lib/module/hooks/useVisibleRanges.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/layouts/BaseLayout.js +15 -16
- package/lib/module/layouts/BaseLayout.js.map +1 -1
- package/lib/module/layouts/ParallaxLayout.js +9 -9
- package/lib/module/layouts/ParallaxLayout.js.map +1 -1
- package/lib/module/layouts/index.js +3 -3
- package/lib/module/layouts/index.js.map +1 -1
- package/lib/module/layouts/normal.js +2 -2
- package/lib/module/layouts/normal.js.map +1 -1
- package/lib/module/layouts/parallax.js +3 -3
- package/lib/module/layouts/parallax.js.map +1 -1
- package/lib/module/layouts/stack.js +20 -28
- package/lib/module/layouts/stack.js.map +1 -1
- package/lib/module/store/index.js +1 -1
- package/lib/module/store/index.js.map +1 -1
- package/lib/module/utils/computedWithAutoFillData.js +4 -4
- package/lib/module/utils/computedWithAutoFillData.js.map +1 -1
- package/lib/module/utils/dealWithAnimation.js +4 -4
- package/lib/module/utils/dealWithAnimation.js.map +1 -1
- package/lib/module/utils/handlerOffsetDirection.js +9 -0
- package/lib/module/utils/handlerOffsetDirection.js.map +1 -0
- package/lib/module/utils/log.js +2 -1
- package/lib/module/utils/log.js.map +1 -1
- package/lib/typescript/Carousel.d.ts +2 -2
- package/lib/typescript/LazyView.d.ts +1 -1
- package/lib/typescript/ScrollViewGesture.d.ts +3 -3
- package/lib/typescript/constants/index.d.ts +1 -1
- package/lib/typescript/hooks/computeNewIndexWhenDataChanges.d.ts +8 -0
- package/lib/typescript/hooks/index.test.d.ts +1 -0
- package/lib/typescript/hooks/useAutoPlay.d.ts +1 -1
- package/lib/typescript/hooks/useCarouselController.d.ts +5 -5
- package/lib/typescript/hooks/useCheckMounted.d.ts +1 -1
- package/lib/typescript/hooks/useCommonVariables.d.ts +2 -2
- package/lib/typescript/hooks/useInitProps.d.ts +2 -2
- package/lib/typescript/hooks/useLayoutConfig.d.ts +2 -2
- package/lib/typescript/hooks/useOffsetX.d.ts +3 -3
- package/lib/typescript/hooks/useOnProgressChange.d.ts +4 -4
- package/lib/typescript/hooks/usePropsErrorBoundary.d.ts +1 -1
- package/lib/typescript/hooks/useVisibleRanges.d.ts +1 -1
- package/lib/typescript/index.d.ts +2 -2
- package/lib/typescript/layouts/BaseLayout.d.ts +5 -4
- package/lib/typescript/layouts/ParallaxLayout.d.ts +5 -5
- package/lib/typescript/layouts/index.d.ts +4 -4
- package/lib/typescript/layouts/parallax.d.ts +15 -15
- package/lib/typescript/layouts/stack.d.ts +15 -15
- package/lib/typescript/store/index.d.ts +2 -2
- package/lib/typescript/types.d.ts +112 -112
- package/lib/typescript/utils/dealWithAnimation.d.ts +1 -1
- package/lib/typescript/utils/handlerOffsetDirection.d.ts +2 -0
- package/package.json +9 -5
- package/src/Carousel.tsx +228 -229
- package/src/LazyView.tsx +6 -7
- package/src/ScrollViewGesture.tsx +251 -257
- package/src/constants/index.ts +10 -9
- package/src/hooks/computeNewIndexWhenDataChanges.ts +51 -0
- package/src/hooks/index.test.ts +82 -0
- package/src/hooks/useAutoPlay.ts +59 -59
- package/src/hooks/useCarouselController.tsx +296 -299
- package/src/hooks/useCheckMounted.ts +9 -9
- package/src/hooks/useCommonVariables.ts +64 -27
- package/src/hooks/useInitProps.ts +71 -70
- package/src/hooks/useLayoutConfig.ts +21 -19
- package/src/hooks/useOffsetX.ts +71 -71
- package/src/hooks/useOnProgressChange.ts +48 -47
- package/src/hooks/usePropsErrorBoundary.ts +27 -26
- package/src/hooks/useVisibleRanges.tsx +39 -39
- package/src/index.tsx +5 -5
- package/src/layouts/BaseLayout.tsx +103 -101
- package/src/layouts/ParallaxLayout.tsx +126 -124
- package/src/layouts/index.tsx +8 -8
- package/src/layouts/normal.ts +16 -16
- package/src/layouts/parallax.ts +62 -61
- package/src/layouts/stack.ts +320 -315
- package/src/store/index.ts +8 -7
- package/src/types.ts +111 -110
- package/src/utils/computedWithAutoFillData.ts +60 -60
- package/src/utils/dealWithAnimation.ts +19 -18
- package/src/utils/handlerOffsetDirection.ts +15 -0
- package/src/utils/log.ts +4 -3
- package/CHANGELOG.md +0 -610
- package/src/.DS_Store +0 -0
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import type { IComputedDirectionTypes } from
|
|
2
|
-
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
* control prev/next item offset.
|
|
9
|
+
* @default 100
|
|
10
|
+
*/
|
|
11
11
|
parallaxScrollingOffset?: number;
|
|
12
12
|
/**
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
* control prev/current/next item offset.
|
|
14
|
+
* @default 0.8
|
|
15
|
+
*/
|
|
16
16
|
parallaxScrollingScale?: number;
|
|
17
17
|
/**
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
mode?:
|
|
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
|
|
2
|
-
import type { IComputedDirectionTypes, CustomConfig } from
|
|
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?:
|
|
10
|
+
snapDirection?: "left" | "right";
|
|
11
11
|
}
|
|
12
12
|
export declare type TStackModeProps = IComputedDirectionTypes<{
|
|
13
13
|
/**
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
mode?:
|
|
14
|
+
* Carousel Animated transitions.
|
|
15
|
+
*/
|
|
16
|
+
mode?: "horizontal-stack" | "vertical-stack";
|
|
17
17
|
/**
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
|
2
|
-
import type { TInitializeCarouselProps } from
|
|
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
|
|
3
|
-
import type { PanGestureHandlerProps } from
|
|
4
|
-
import type { AnimatedStyleProp, SharedValue, WithSpringConfig, WithTimingConfig } from
|
|
5
|
-
import type Animated from
|
|
6
|
-
import type { TParallaxModeProps } from
|
|
7
|
-
import type { TStackModeProps } from
|
|
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
|
-
|
|
11
|
-
|
|
10
|
+
* Layout items vertically instead of horizontally
|
|
11
|
+
*/
|
|
12
12
|
vertical: true;
|
|
13
13
|
/**
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
* Layout items vertically instead of horizontally
|
|
15
|
+
*/
|
|
16
16
|
/**
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
* Specified carousel container width.
|
|
18
|
+
*/
|
|
19
19
|
width?: number;
|
|
20
20
|
height: number;
|
|
21
21
|
}) | (T & HP & {
|
|
22
22
|
/**
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
* Layout items vertically instead of horizontally
|
|
24
|
+
*/
|
|
25
25
|
vertical?: false;
|
|
26
26
|
/**
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
* Layout items vertically instead of horizontally
|
|
28
|
+
*/
|
|
29
29
|
/**
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
* Specified carousel container width.
|
|
31
|
+
*/
|
|
32
32
|
width: number;
|
|
33
33
|
height?: number;
|
|
34
34
|
});
|
|
35
|
-
export
|
|
36
|
-
type?:
|
|
35
|
+
export interface CustomConfig {
|
|
36
|
+
type?: "negative" | "positive";
|
|
37
37
|
viewCount?: number;
|
|
38
|
-
}
|
|
39
|
-
export
|
|
40
|
-
type:
|
|
38
|
+
}
|
|
39
|
+
export interface WithSpringAnimation {
|
|
40
|
+
type: "spring";
|
|
41
41
|
config: WithSpringConfig;
|
|
42
|
-
}
|
|
43
|
-
export
|
|
44
|
-
type:
|
|
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
|
-
|
|
52
|
-
|
|
51
|
+
* The default animated value of the carousel.
|
|
52
|
+
*/
|
|
53
53
|
defaultScrollOffsetValue?: SharedValue<number>;
|
|
54
54
|
/**
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
* Carousel loop playback.
|
|
56
|
+
* @default true
|
|
57
|
+
*/
|
|
58
58
|
loop?: boolean;
|
|
59
59
|
/**
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
* Carousel items data set.
|
|
61
|
+
*/
|
|
62
62
|
data: T[];
|
|
63
63
|
/**
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
-
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
* Default index
|
|
73
|
+
* @default 0
|
|
74
|
+
*/
|
|
75
75
|
defaultIndex?: number;
|
|
76
76
|
/**
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
* Auto play
|
|
78
|
+
*/
|
|
79
79
|
autoPlay?: boolean;
|
|
80
80
|
/**
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
* Auto play
|
|
82
|
+
* @description reverse playback
|
|
83
|
+
*/
|
|
84
84
|
autoPlayReverse?: boolean;
|
|
85
85
|
/**
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
* Auto play
|
|
87
|
+
* @description playback interval
|
|
88
|
+
*/
|
|
89
89
|
autoPlayInterval?: number;
|
|
90
90
|
/**
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
* Time a scroll animation takes to finish
|
|
92
|
+
* @default 500 (ms)
|
|
93
|
+
*/
|
|
94
94
|
scrollAnimationDuration?: number;
|
|
95
95
|
/**
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
* Carousel container style
|
|
97
|
+
*/
|
|
98
98
|
style?: StyleProp<ViewStyle>;
|
|
99
99
|
/**
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
panGestureHandlerProps?: Partial<Omit<PanGestureHandlerProps,
|
|
100
|
+
* PanGestureHandler props
|
|
101
|
+
*/
|
|
102
|
+
panGestureHandlerProps?: Partial<Omit<PanGestureHandlerProps, "onHandlerStateChange" | "enabled">>;
|
|
103
103
|
/**
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
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
|
-
|
|
112
|
-
|
|
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
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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
|
-
|
|
129
|
-
|
|
130
|
-
|
|
128
|
+
* If false, Carousel will not respond to any gestures.
|
|
129
|
+
* @default true
|
|
130
|
+
*/
|
|
131
131
|
enabled?: boolean;
|
|
132
132
|
/**
|
|
133
|
-
|
|
134
|
-
|
|
133
|
+
* Specifies the scrolling animation effect.
|
|
134
|
+
*/
|
|
135
135
|
withAnimation?: WithAnimation;
|
|
136
136
|
/**
|
|
137
|
-
|
|
138
|
-
|
|
137
|
+
* Used to locate this view in end-to-end tests.
|
|
138
|
+
*/
|
|
139
139
|
testID?: string;
|
|
140
140
|
/**
|
|
141
|
-
|
|
142
|
-
|
|
141
|
+
* Custom carousel config.
|
|
142
|
+
*/
|
|
143
143
|
customConfig?: () => CustomConfig;
|
|
144
144
|
/**
|
|
145
|
-
|
|
146
|
-
|
|
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
|
-
|
|
151
|
-
|
|
150
|
+
* Render carousel item.
|
|
151
|
+
*/
|
|
152
152
|
renderItem: CarouselRenderItem<T>;
|
|
153
153
|
/**
|
|
154
|
-
|
|
155
|
-
|
|
154
|
+
* Callback fired when navigating to an item.
|
|
155
|
+
*/
|
|
156
156
|
onSnapToItem?: (index: number) => void;
|
|
157
157
|
/**
|
|
158
|
-
|
|
159
|
-
|
|
158
|
+
* On scroll begin
|
|
159
|
+
*/
|
|
160
160
|
onScrollBegin?: () => void;
|
|
161
161
|
/**
|
|
162
|
-
|
|
163
|
-
|
|
162
|
+
* On scroll end
|
|
163
|
+
*/
|
|
164
164
|
onScrollEnd?: (index: number) => void;
|
|
165
165
|
/**
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
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
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
prev: (opts?: Omit<TCarouselActionOptions,
|
|
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
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
next: (opts?: Omit<TCarouselActionOptions,
|
|
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
|
-
|
|
185
|
-
|
|
184
|
+
* Get current item index
|
|
185
|
+
*/
|
|
186
186
|
getCurrentIndex: () => number;
|
|
187
187
|
/**
|
|
188
|
-
|
|
189
|
-
|
|
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
|
|
1
|
+
import type { WithAnimation } from "../types";
|
|
2
2
|
export declare function dealWithAnimation(withAnimation: WithAnimation): (value: number, cb: (isFinished: boolean) => void) => number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-reanimated-carousel",
|
|
3
|
-
"version": "3.1.
|
|
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": "
|
|
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": "^
|
|
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": {
|