mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
[react-native-swipe-gestures]: add type definitions (#35465)
This commit is contained in:
parent
a85998b8f2
commit
5845f55fba
34
types/react-native-swipe-gestures/index.d.ts
vendored
Normal file
34
types/react-native-swipe-gestures/index.d.ts
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
// Type definitions for react-native-swipe-gestures 1.0
|
||||
// Project: https://github.com/glepur/react-native-swipe-gestures
|
||||
// Definitions by: Ian <https://github.com/ian-rudge>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import { Component } from 'react';
|
||||
import { PanResponderGestureState } from 'react-native';
|
||||
|
||||
export interface SwipeDirections {
|
||||
SWIPE_UP: 'SWIPE_UP';
|
||||
SWIPE_DOWN: 'SWIPE_DOWN';
|
||||
SWIPE_LEFT: 'SWIPE_LEFT';
|
||||
SWIPE_RIGHT: 'SWIPE_RIGHT';
|
||||
}
|
||||
|
||||
export const swipeDirections: SwipeDirections;
|
||||
|
||||
export interface GestureRecognizerConfig {
|
||||
velocityThreshold?: number;
|
||||
directionalOffsetThreshold?: number;
|
||||
gestureIsClickThreshold?: number;
|
||||
}
|
||||
|
||||
export interface GestureRecognizerProps {
|
||||
config?: GestureRecognizerConfig;
|
||||
onSwipe?: (gestureName: string, state: PanResponderGestureState) => void;
|
||||
onSwipeUp?: (state: PanResponderGestureState) => void;
|
||||
onSwipeDown?: (state: PanResponderGestureState) => void;
|
||||
onSwipeLeft?: (state: PanResponderGestureState) => void;
|
||||
onSwipeRight?: (state: PanResponderGestureState) => void;
|
||||
}
|
||||
|
||||
export default class GestureRecognizer extends Component<GestureRecognizerProps> {}
|
||||
@ -0,0 +1,25 @@
|
||||
import * as React from 'react';
|
||||
import GestureRecognizer, { GestureRecognizerConfig, swipeDirections } from 'react-native-swipe-gestures';
|
||||
|
||||
const { SWIPE_UP, SWIPE_DOWN, SWIPE_LEFT, SWIPE_RIGHT } = swipeDirections;
|
||||
|
||||
const config: GestureRecognizerConfig = {
|
||||
velocityThreshold: 0.3,
|
||||
directionalOffsetThreshold: 80,
|
||||
gestureIsClickThreshold: 5,
|
||||
};
|
||||
|
||||
class Example extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<GestureRecognizer
|
||||
config={config}
|
||||
onSwipe={(direction, state) => {}}
|
||||
onSwipeUp={state => {}}
|
||||
onSwipeDown={state => {}}
|
||||
onSwipeLeft={state => {}}
|
||||
onSwipeRight={state => {}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
24
types/react-native-swipe-gestures/tsconfig.json
Normal file
24
types/react-native-swipe-gestures/tsconfig.json
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"jsx": "react"
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"react-native-swipe-gestures-tests.tsx"
|
||||
]
|
||||
}
|
||||
1
types/react-native-swipe-gestures/tslint.json
Normal file
1
types/react-native-swipe-gestures/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user