// Type definitions for react-motion // Project: https://github.com/chenglou/react-motion // Definitions by: Stepan Mikhaylyuk // Definitions: https://github.com/borisyankov/DefinitelyTyped /// declare module "react-motion" { import { Component } from 'react'; // your typical style object given in props. Maps to a number or a spring config export type Style = { [key: string]: number | OpaqueConfig }; // the interpolating style object, with the same keys as the above Style object, // with the values mapped to numbers, naturally export type PlainStyle = { [key: string]: number }; // internal velocity object. Similar to PlainStyle, but whose numbers represent // speed. Might be exposed one day. export type Velocity = { [key: string]: number }; interface SpringHelperConfig { stiffness: number; damping: number; /** * Specifies both the rounding of the interpolated value and the speed (internal). */ precision?: number; // TODO: add onRest. Not public yet } export interface OpaqueConfig { val: number; stiffness: number; damping: number; precision: number; // TODO: add onRest. Not public yet } interface MotionProps { defaultStyle?: any; style: any; } export class Motion extends Component { } // === TransitionMotion === interface TransitionStyle { key: any; // unique ID to identify component across render animations data?: any; // optional data you want to carry along the style, e.g. itemText style: Style; // actual style you're passing } interface TransitionPlainStyle { key: any; data?: any; // same as TransitionStyle, passed as argument to style/children function style: PlainStyle; } type InterpolateFunction = (previousInterpolatedStyles?: Array) => Array; type Styles = Array | InterpolateFunction; interface TransitionProps { defaultStyles?: Array; styles: Styles; children: (interpolatedStyles: Array) => __React.ReactElement; willEnter?: (styleThatEntered: TransitionStyle) => PlainStyle; willLeave?: (styleThatLeft: TransitionStyle) => Style; } export class TransitionMotion extends Component { } interface StaggeredMotionProps { defaultStyles?: Array; styles: (previousInterpolatedStyles?: Array) => Array