-
Notifications
You must be signed in to change notification settings - Fork 751
Expand file tree
/
Copy pathtypes.ts
More file actions
114 lines (110 loc) · 3.2 KB
/
types.ts
File metadata and controls
114 lines (110 loc) · 3.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import {ScrollViewProps, StyleProp, ViewStyle, NativeSyntheticEvent, NativeScrollEvent, Animated} from 'react-native';
// @ts-expect-error No typings available for 'deprecated-react-native-prop-types'
import {PointPropType} from 'deprecated-react-native-prop-types';
import {PageControlProps} from '../pageControl';
export enum PageControlPosition {
OVER = 'over',
UNDER = 'under'
}
export interface CarouselProps extends ScrollViewProps {
/**
* the first page to start with
*/
initialPage?: number;
/**
* the page width (all pages should have the same width). Does not work if passing 'loop' prop
*/
pageWidth?: number;
/**
* the page height (all pages should have the same height).
*/
pageHeight?: number;
/**
* the spacing between the items
*/
itemSpacings?: number;
/**
* Horizontal margin for the container
*/
containerMarginHorizontal?: number;
/**
* Vertical padding for the container.
* Sometimes needed when there are overflows that are cut in Android.
*/
containerPaddingVertical?: number;
/**
* if true, will have infinite scroll (do not turn on for vertical scrolling)
*/
loop?: boolean;
/**
* callback for when page has changed
*/
onChangePage?: (newPageIndex: number, oldPageIndex: number, info: {isAutoScrolled: boolean}) => void;
/**
* callback for onScroll event of the internal ScrollView
*/
onScroll?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
/**
* Should the container be animated (send the animation style via containerStyle)
*/
animated?: boolean;
/**
* the carousel style
*/
containerStyle?: StyleProp<ViewStyle>;
/**
* PageControl component props
*/
pageControlProps?: Partial<PageControlProps>;
/**
* The position of the PageControl component ['over', 'under'], otherwise it won't display
*/
pageControlPosition?: PageControlPosition | `${PageControlPosition}`;
/**
* whether to show a page counter (will not work with 'pageWidth' prop)
*/
showCounter?: boolean;
/**
* the counter's container style
*/
counterContainerStyle?: StyleProp<ViewStyle>;
/**
* the counter's text style
*/
counterTextStyle?: StyleProp<ViewStyle>;
/**
* will block multiple pages scroll (will not work with 'pageWidth' prop)
*/
pagingEnabled?: boolean;
/**
* Whether to layout Carousel for accessibility
*/
allowAccessibleLayout?: boolean;
/**
* Whether to switch automatically between the pages
*/
autoplay?: boolean;
/**
* the amount of ms to wait before switching to the next page, in case autoplay is on
*/
autoplayInterval?: number;
/**
* When true the scroll view's children are arranged horizontally in a row
* instead of vertically in a column. The default value is true.
*/
horizontal?: boolean | null;
/**
* Pass to attach to ScrollView's Animated.event in order to animated elements base on
* Carousel scroll offset (pass new Animated.ValueXY())
*/
animatedScrollOffset?: Animated.ValueXY;
}
export interface CarouselState {
containerWidth?: number;
currentPage: number;
currentStandingPage: number;
pageWidth: number;
pageHeight: number;
initialOffset: PointPropType;
prevProps: CarouselProps;
}