mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
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
61 lines
1.8 KiB
TypeScript
61 lines
1.8 KiB
TypeScript
/** @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);
|
||
|
||
// Can’t 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;
|
||
}
|