mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-02 14:38:20 +08:00
Add types for react-hammerjs@0.5 (#27079)
This commit is contained in:
committed by
Mohamed Hegazy
parent
917cb109d0
commit
5db2874431
45
types/react-hammerjs/index.d.ts
vendored
Normal file
45
types/react-hammerjs/index.d.ts
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
// Type definitions for react-hammerjs 0.5
|
||||
// Project: https://github.com/JedWatson/react-hammerjs#readme
|
||||
// Definitions by: Jason Unger <https://github.com/jsonunger>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import * as Hammer from 'hammerjs';
|
||||
import * as React from 'react';
|
||||
|
||||
type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;
|
||||
|
||||
type HammerOptionsWithRecognizers = Omit<HammerOptions, 'recognizers'> & {
|
||||
recognizers?: { [gesture: string]: RecognizerOptions };
|
||||
};
|
||||
|
||||
declare namespace ReactHammer {
|
||||
interface ReactHammerProps {
|
||||
direction?: number;
|
||||
options?: HammerOptionsWithRecognizers;
|
||||
recognizeWith?: { [gesture: string]: Recognizer | string };
|
||||
vertical?: boolean;
|
||||
action?: HammerListener;
|
||||
onDoubleTap?: HammerListener;
|
||||
onPan?: HammerListener;
|
||||
onPanCancel?: HammerListener;
|
||||
onPanEnd?: HammerListener;
|
||||
onPanStart?: HammerListener;
|
||||
onPinch?: HammerListener;
|
||||
onPinchCancel?: HammerListener;
|
||||
onPinchEnd?: HammerListener;
|
||||
onPinchIn?: HammerListener;
|
||||
onPinchStart?: HammerListener;
|
||||
onPress?: HammerListener;
|
||||
onPressUp?: HammerListener;
|
||||
onRotate?: HammerListener;
|
||||
onRotateCancel?: HammerListener;
|
||||
onRotateEnd?: HammerListener;
|
||||
onRotateMove?: HammerListener;
|
||||
onRotateStart?: HammerListener;
|
||||
onSwipe?: HammerListener;
|
||||
onTap?: HammerListener;
|
||||
}
|
||||
}
|
||||
declare const ReactHammer: React.ComponentClass<ReactHammer.ReactHammerProps>;
|
||||
export = ReactHammer;
|
||||
17
types/react-hammerjs/react-hammerjs-tests.tsx
Normal file
17
types/react-hammerjs/react-hammerjs-tests.tsx
Normal file
@@ -0,0 +1,17 @@
|
||||
import * as React from 'react';
|
||||
import Hammer from 'react-hammerjs';
|
||||
|
||||
class ReactHammer extends React.Component<Hammer.ReactHammerProps> {
|
||||
swipe: Hammer.ReactHammerProps['onSwipe'] = input => {
|
||||
console.log(input.deltaX);
|
||||
}
|
||||
|
||||
render() {
|
||||
const { children, ...props } = this.props;
|
||||
return (
|
||||
<Hammer onSwipe={this.swipe} {...props}>
|
||||
{children}
|
||||
</Hammer>
|
||||
);
|
||||
}
|
||||
}
|
||||
26
types/react-hammerjs/tsconfig.json
Normal file
26
types/react-hammerjs/tsconfig.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"jsx": "react",
|
||||
"esModuleInterop": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"react-hammerjs-tests.tsx"
|
||||
]
|
||||
}
|
||||
1
types/react-hammerjs/tslint.json
Normal file
1
types/react-hammerjs/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user