UNPKG

4.6 kBTypeScriptView Raw
1import type { ReactNode } from 'react';
2import type * as ReactNative from 'react-native';
3export declare type TransitionStyle = 'scroll' | 'curl';
4export declare type Orientation = 'horizontal' | 'vertical';
5export declare type OverScrollMode = 'auto' | 'always' | 'never';
6export declare type PageScrollState = 'idle' | 'dragging' | 'settling';
7export declare type ViewPagerOnPageScrollEvent = ReactNative.NativeSyntheticEvent<ViewPagerOnPageScrollEventData>;
8export interface ViewPagerOnPageScrollEventData {
9 position: number;
10 offset: number;
11}
12export declare type ViewPagerOnPageSelectedEvent = ReactNative.NativeSyntheticEvent<ViewPagerOnPageSelectedEventData>;
13export interface ViewPagerOnPageSelectedEventData {
14 position: number;
15}
16export declare type PageScrollStateChangedNativeEvent = ReactNative.NativeSyntheticEvent<PageScrollStateChangedEvent>;
17export interface PageScrollStateChangedEvent {
18 pageScrollState: PageScrollState;
19}
20export interface ViewPagerProps {
21 /**
22 * Index of initial page that should be selected. Use `setPage` method to
23 * update the page, and `onPageSelected` to monitor page changes
24 */
25 initialPage?: number;
26 /**
27 * When false, the content does not scroll.
28 * The default value is true.
29 */
30 scrollEnabled?: boolean;
31 /**
32 * Executed when transitioning between pages (ether because of animation for
33 * the requested page change or when user is swiping/dragging between pages)
34 * The `event.nativeEvent` object for this callback will carry following data:
35 * - position - index of first page from the left that is currently visible
36 * - offset - value from range [0,1) describing stage between page transitions.
37 * Value x means that (1 - x) fraction of the page at "position" index is
38 * visible, and x fraction of the next page is visible.
39 */
40 onPageScroll?: (event: ViewPagerOnPageScrollEvent) => void;
41 /**
42 * This callback will be called once ViewPager finish navigating to selected page
43 * (when user swipes between pages). The `event.nativeEvent` object passed to this
44 * callback will have following fields:
45 * - position - index of page that has been selected
46 */
47 onPageSelected?: (event: ViewPagerOnPageSelectedEvent) => void;
48 /**
49 * Function called when the page scrolling state has changed.
50 * The page scrolling state can be in 3 states:
51 * - idle, meaning there is no interaction with the page scroller happening at the time
52 * - dragging, meaning there is currently an interaction with the page scroller
53 * - settling, meaning that there was an interaction with the page scroller, and the
54 * page scroller is now finishing it's closing or opening animation
55 */
56 onPageScrollStateChanged?: (event: PageScrollStateChangedNativeEvent) => void;
57 /**
58 * Determines whether the keyboard gets dismissed in response to a drag.
59 * - 'none' (the default), drags do not dismiss the keyboard.
60 * - 'on-drag', the keyboard is dismissed when a drag begins.
61 */
62 keyboardDismissMode?: 'none' | 'on-drag';
63 /**
64 * Blank space to show between pages. This is only visible while scrolling, pages are still
65 * edge-to-edge.
66 */
67 pageMargin?: number;
68 style?: ReactNative.StyleProp<ReactNative.ViewStyle>;
69 /**
70 * Set the number of pages that should be retained to either side
71 * of the currently visible page(s). Pages beyond this limit will
72 * be recreated from the adapter when needed.
73 * Defaults to RecyclerView's caching strategy.
74 * The given value must either be larger than 0.
75 */
76 offscreenPageLimit?: number;
77 children: ReactNode;
78 /**
79 * If a parent `View` wants to prevent a child `View` from becoming responder
80 * on a move, it should have this handler which returns `true`.
81 *
82 * `View.props.onMoveShouldSetResponderCapture: (event) => [true | false]`,
83 * where `event` is a synthetic touch event as described above.
84 *
85 * See http://facebook.github.io/react-native/docs/view.html#onMoveShouldsetrespondercapture
86 */
87 onMoveShouldSetResponderCapture?: (event: ReactNative.GestureResponderEvent) => boolean;
88 /**
89 * iOS only
90 */
91 orientation?: Orientation;
92 transitionStyle?: TransitionStyle;
93 showPageIndicator?: boolean;
94 /**
95 * Android only
96 */
97 overScrollMode?: OverScrollMode;
98 /**
99 * Determines whether it's possible to overscroll a bit
100 * after reaching end or very beginning of pages.
101 */
102 overdrag?: boolean;
103}