Skip to content

Commit cc44411

Browse files
danilobuergerferrannp
authored andcommitted
chore: added typings (#10)
imported from @types/react-native
1 parent 603556d commit cc44411

File tree

2 files changed

+84
-0
lines changed

2 files changed

+84
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "1.1.1",
44
"description": "React Native ViewPager native view",
55
"main": "js/index.js",
6+
"types": "typings/index.d.ts",
67
"scripts": {
78
"start": "node node_modules/react-native/local-cli/cli.js start",
89
"test": "echo \"Error: no test specified\" && exit 1",

typings/index.d.ts

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import * as React from "react";
2+
import * as ReactNative from "react-native";
3+
4+
export interface ViewPagerAndroidOnPageScrollEventData {
5+
position: number;
6+
offset: number;
7+
}
8+
9+
export interface ViewPagerAndroidOnPageSelectedEventData {
10+
position: number;
11+
}
12+
13+
export interface ViewPagerAndroidProps extends ReactNative.ViewProps {
14+
/**
15+
* Index of initial page that should be selected. Use `setPage` method to
16+
* update the page, and `onPageSelected` to monitor page changes
17+
*/
18+
initialPage?: number;
19+
20+
/**
21+
* When false, the content does not scroll.
22+
* The default value is true.
23+
*/
24+
scrollEnabled?: boolean;
25+
26+
/**
27+
* Executed when transitioning between pages (ether because of animation for
28+
* the requested page change or when user is swiping/dragging between pages)
29+
* The `event.nativeEvent` object for this callback will carry following data:
30+
* - position - index of first page from the left that is currently visible
31+
* - offset - value from range [0,1) describing stage between page transitions.
32+
* Value x means that (1 - x) fraction of the page at "position" index is
33+
* visible, and x fraction of the next page is visible.
34+
*/
35+
onPageScroll?: (event: ReactNative.NativeSyntheticEvent<ViewPagerAndroidOnPageScrollEventData>) => void;
36+
37+
/**
38+
* This callback will be called once ViewPager finish navigating to selected page
39+
* (when user swipes between pages). The `event.nativeEvent` object passed to this
40+
* callback will have following fields:
41+
* - position - index of page that has been selected
42+
*/
43+
onPageSelected?: (event: ReactNative.NativeSyntheticEvent<ViewPagerAndroidOnPageSelectedEventData>) => void;
44+
45+
/**
46+
* Function called when the page scrolling state has changed.
47+
* The page scrolling state can be in 3 states:
48+
* - idle, meaning there is no interaction with the page scroller happening at the time
49+
* - dragging, meaning there is currently an interaction with the page scroller
50+
* - settling, meaning that there was an interaction with the page scroller, and the
51+
* page scroller is now finishing it's closing or opening animation
52+
*/
53+
onPageScrollStateChanged?: (state: "Idle" | "Dragging" | "Settling") => void;
54+
55+
/**
56+
* Determines whether the keyboard gets dismissed in response to a drag.
57+
* - 'none' (the default), drags do not dismiss the keyboard.
58+
* - 'on-drag', the keyboard is dismissed when a drag begins.
59+
*/
60+
keyboardDismissMode?: "none" | "on-drag";
61+
62+
/**
63+
* Blank space to show between pages. This is only visible while scrolling, pages are still
64+
* edge-to-edge.
65+
*/
66+
pageMargin?: number;
67+
}
68+
69+
declare class ViewPagerAndroidComponent extends React.Component<ViewPagerAndroidProps> {}
70+
declare const ViewPagerAndroidBase: ReactNative.Constructor<ReactNative.NativeMethodsMixin> & typeof ViewPagerAndroidComponent;
71+
export default class ViewPagerAndroid extends ViewPagerAndroidBase {
72+
/**
73+
* A helper function to scroll to a specific page in the ViewPager.
74+
* The transition between pages will be animated.
75+
*/
76+
public setPage(selectedPage: number): void;
77+
78+
/**
79+
* A helper function to scroll to a specific page in the ViewPager.
80+
* The transition between pages will *not* be animated.
81+
*/
82+
public setPageWithoutAnimation(selectedPage: number): void;
83+
}

0 commit comments

Comments
 (0)