[react-hammerjs]: Update to v1.0 (#28508)

This commit is contained in:
Cecchi MacNaughton
2018-09-10 15:59:45 -07:00
committed by Ryan Cavanaugh
parent a6e137333d
commit 4203215339
5 changed files with 98 additions and 5 deletions

View File

@@ -1,21 +1,30 @@
// Type definitions for react-hammerjs 0.5
// Type definitions for react-hammerjs 1.0
// Project: https://github.com/JedWatson/react-hammerjs#readme
// Definitions by: Jason Unger <https://github.com/jsonunger>
// Cecchi MacNaughton <https://github.com/cecchi>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
import * as Hammer from 'hammerjs';
import * as React from 'react';
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'> & {
type HammerOptionsWithRecognizers = Omit<HammerOptions, "recognizers"> & {
recognizers?: { [gesture: string]: RecognizerOptions };
};
declare namespace ReactHammer {
interface ReactHammerProps {
direction?: number;
direction?:
| "DIRECTION_NONE"
| "DIRECTION_LEFT"
| "DIRECTION_RIGHT"
| "DIRECTION_UP"
| "DIRECTION_DOWN"
| "DIRECTION_HORIZONTAL"
| "DIRECTION_VERTICAL"
| "DIRECTION_ALL";
options?: HammerOptionsWithRecognizers;
recognizeWith?: { [gesture: string]: Recognizer | string };
vertical?: boolean;

45
types/react-hammerjs/v0/index.d.ts vendored Normal file
View 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;

View 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>
);
}
}

View File

@@ -0,0 +1,21 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es6", "dom"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../../",
"typeRoots": ["../../"],
"paths": {
"react-hammerjs": ["react-hammerjs/v0"]
},
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"jsx": "react",
"esModuleInterop": true
},
"files": ["index.d.ts", "react-hammerjs-tests.tsx"]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }