Upgrade react-swipeable to v4.0

This commit is contained in:
Konstantin Vasilev
2017-06-05 11:40:42 +03:00
parent 163f4438df
commit a85c080ce2
3 changed files with 58 additions and 45 deletions

View File

@@ -1,29 +1,19 @@
// Type definitions for react-swipeable 3.3.1
// Type definitions for react-swipeable 4.0
// Project: https://www.npmjs.com/package/react-swipeable
// Definitions by: Giedrius Grabauskas <https://github.com/GiedriusGrabauskas>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
// TypeScript Version: 2.2
///<reference types='react' />
declare module 'react-swipeable' {
import * as React from 'react';
declare namespace ReactSwipeableModule {
interface onSwipingCallback {
(event: React.TouchEvent<any>, deltaX: number, deltaY: number, absX: number, absY: number, velocity: number): void;
}
type onSwipingCallback = (event: React.TouchEvent<HTMLElement>, deltaX: number, deltaY: number, absX: number, absY: number, velocity: number) => void;
type OnSwipedCallback = (event: React.TouchEvent<HTMLElement>, deltaX: number, deltaY: number, isFlick: boolean, velocity: number) => void;
type OnSwipedDirectionCallback = (event: React.TouchEvent<HTMLElement>, delta: number, isFlick: boolean) => void;
type OnSwipingDirectionCallback = (event: React.TouchEvent<HTMLElement>, delta: number) => void;
type OnTapCallback = (event: React.TouchEvent<HTMLElement>) => void;
interface OnSwipedCallback {
(event: React.TouchEvent<any>, deltaX: number, deltaY: number, isFlick: boolean, velocity: number): void;
}
interface OnSwipedDirectionCallback {
(event: React.TouchEvent<any>, delta: number, isFlick: boolean): void;
}
interface OnSwipingDirectionCallback {
(event: React.TouchEvent<any>, delta: number): void;
}
interface Props {
interface Props extends React.ClassAttributes<ReactSwipeable>, React.HTMLAttributes<HTMLElement> {
onSwiped?: OnSwipedCallback;
onSwiping?: onSwipingCallback;
onSwipingUp?: OnSwipingDirectionCallback;
@@ -34,18 +24,18 @@ declare namespace ReactSwipeableModule {
onSwipedRight?: OnSwipedDirectionCallback;
onSwipedDown?: OnSwipedDirectionCallback;
onSwipedLeft?: OnSwipedDirectionCallback;
onTap?: OnTapCallback;
flickThreshold?: number;
delta?: number;
preventDefaultTouchmoveEvent?: boolean;
stopPropagation?: boolean;
nodeName?: string;
trackMouse?: boolean;
children?: React.ReactNode;
}
interface ReactSwipeable extends React.ComponentClass<Props> { }
class ReactSwipeable extends React.Component<Props, void> {}
namespace ReactSwipeable {}
}
declare module "react-swipeable" {
let module: ReactSwipeableModule.ReactSwipeable;
export = module;
export = ReactSwipeable;
}

View File

@@ -1,26 +1,46 @@
import Swipeable = require('react-swipeable');
import React = require('react');
import * as React from 'react';
import * as Swipeable from 'react-swipeable';
var SampleComponent = React.createClass({
render: function () {
class SampleComponent extends React.PureComponent<void, void> {
private handleSwiped = () => {};
private handleSwiping = () => {};
private handleSwipingUp = () => {};
private handleSwipingRight = () => {};
private handleSwipingDown = () => {};
private handleSwipingLeft = () => {};
private handleSwipedUp = () => {};
private handleSwipedRight = () => {};
private handleSwipedDown = () => {};
private handleSwipedLeft = () => {};
private handleTap = () => {};
private handleClick = () => {};
render() {
return (
<Swipeable
onSwiping={this.swiping}
onSwipingUp={this.swipingUp}
onSwipingRight={this.swipingRight}
onSwipingDown={this.swipingDown}
onSwipingLeft={this.swipingLeft}
onSwipedUp={this.swipedUp}
onSwipedRight={this.swipedRight}
onSwipedDown={this.swipedDown}
onSwipedLeft={this.swipedLeft}
onSwiped={this.handleSwipeAction}
preventDefaultTouchmoveEvent={false}
nodeName={"swipe"}>
onSwiped={this.handleSwiped}
onSwiping={this.handleSwiping}
onSwipingUp={this.handleSwipingUp}
onSwipingRight={this.handleSwipingRight}
onSwipingDown={this.handleSwipingDown}
onSwipingLeft={this.handleSwipingLeft}
onSwipedUp={this.handleSwipedUp}
onSwipedRight={this.handleSwipedRight}
onSwipedDown={this.handleSwipedDown}
onSwipedLeft={this.handleSwipedLeft}
onTap={this.handleTap}
flickThreshold={10}
delta={10}
preventDefaultTouchmoveEvent
stopPropagation
nodeName="swipe"
trackMouse
onClick={this.handleClick}
>
<div>
This element can be swiped
</div>
</Swipeable>
)
);
}
})
}

View File

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