Add definitions for react-swipeable-views.

This commit is contained in:
Michal Ledin 2016-03-14 22:55:31 +03:00
parent 0cd5f0a148
commit 65ede6d2f3
2 changed files with 68 additions and 0 deletions

View File

@ -0,0 +1,31 @@
/// <reference path="react-swipeable-views.d.ts"/>
import * as React from 'react';
import SwipeableViews from 'react-swipeable-views';
const onChangeIndex = (indexNew:number, indexLatest:number) => {
console.log('New index: ' + indexNew + ', latest index' + indexLatest);
};
const onSwitching = (index:number) => {
console.log('Switching to ' + index);
};
const style:React.CSSProperties = {
height: 300
};
React.createElement(SwipeableViews, {
containerStyle: style,
disabled: false,
index: 0,
onChangeIndex: onChangeIndex,
onSwitching: onSwitching,
resistance: false,
slideStyle: style,
style: style,
threshold: 100
});
React.createElement(SwipeableViews, {});

View File

@ -0,0 +1,37 @@
// Type definitions for react-swipeable-views
// Project: https://github.com/oliviertassinari/react-swipeable-views
// Definitions by: Michael Ledin <https://github.com/mxl>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
///<reference path='../react/react.d.ts' />
declare namespace ReactSwipeableViews {
import React = __React;
export interface SwipeableViewsProps extends React.Props<SwipeableViews> {
containerStyle?: React.CSSProperties;
disabled?: boolean;
index?: number;
onChangeIndex?: (indexNew:number, indexLatest:number) => void;
onSwitching?: (index:number) => void;
resistance?: boolean;
slideStyle?: React.CSSProperties;
style?: React.CSSProperties;
threshold?: number;
}
interface SwipeableViewsState {
indexCurrent?: number;
indexLatest?: number;
isDragging?: boolean;
isFirstRender?: boolean;
heightLatest?: number;
}
export class SwipeableViews extends React.Component<SwipeableViewsProps, SwipeableViewsState> {
}
}
declare module 'react-swipeable-views' {
export default ReactSwipeableViews.SwipeableViews;
}