DefinitelyTyped/types/react-virtualized/WindowScroller.d.ts
Kalle Ott 8484faf774 update for react-virtualized 9.4
replaced single declaration file with multiple files to represent the module structure of react-virtualized. 
This makes the future maintanance easier, because changes in the lib can be easier mirrored in the corresponding declaration file.
This typings update should be the last with large breaking changes
2017-03-27 21:23:45 +02:00

61 lines
1.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/** @flow */
import { Validator, Requireable, PureComponent } from 'react'
export type WindowScrollerChildProps = {
height: number,
isScrolling: boolean,
scrollTop: number
};
export type WindowScrollerProps = {
children?: (props: WindowScrollerChildProps) => React.ReactNode;
onResize?: (prams: { height: number }) => void;
onScroll?: (params: { scrollTop: number }) => void;
scrollElement?: HTMLElement;
}
export type WindowScrollerState = {
height: number,
isScrolling: boolean,
scrollTop: number
}
export class WindowScroller extends PureComponent<WindowScrollerProps, WindowScrollerState> {
static propTypes: {
/**
* Function responsible for rendering children.
* This function should implement the following signature:
* ({ height, isScrolling, scrollTop }) => PropTypes.element
*/
children: Validator<(props: WindowScrollerChildProps) => React.ReactNode>,
/** Callback to be invoked on-resize: ({ height }) */
onResize: Validator<(params: { height: number }) => void>,
/** Callback to be invoked on-scroll: ({ scrollTop }) */
onScroll: Validator<(params: { scrollTop: number }) => void>,
/** Element to attach scroll event listeners. Defaults to window. */
scrollElement: HTMLElement
};
static defaultProps: {
onResize: () => {},
onScroll: () => {}
};
constructor(props: WindowScrollerProps);
// Cant use defaultProps for scrollElement without breaking server-side rendering
readonly scrollElement: HTMLElement | Window;
updatePosition(scrollElement?: HTMLElement): void;
componentDidMount(): void;
componentWillReceiveProps(nextProps: WindowScrollerProps): void;
componentWillUnmount(): void;
render(): JSX.Element;
}