1 | import type * as PropTypes from "prop-types";
|
2 | import { PureComponent } from "react";
|
3 |
|
4 | export type OnScrollParams = {
|
5 | clientHeight: number;
|
6 | clientWidth: number;
|
7 | scrollHeight: number;
|
8 | scrollLeft: number;
|
9 | scrollTop: number;
|
10 | scrollWidth: number;
|
11 | };
|
12 |
|
13 | export type ScrollSyncChildProps = {
|
14 | clientHeight: number;
|
15 | clientWidth: number;
|
16 | onScroll: (params: OnScrollParams) => void;
|
17 | scrollHeight: number;
|
18 | scrollLeft: number;
|
19 | scrollTop: number;
|
20 | scrollWidth: number;
|
21 | };
|
22 |
|
23 | export type ScrollSyncProps = {
|
24 | |
25 |
|
26 |
|
27 |
|
28 |
|
29 | children: (props: ScrollSyncChildProps) => React.ReactNode;
|
30 | |
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 | [key: string]: any;
|
38 | };
|
39 |
|
40 | export type ScrollSyncState = {
|
41 | clientHeight: number;
|
42 | clientWidth: number;
|
43 | scrollHeight: number;
|
44 | scrollLeft: number;
|
45 | scrollTop: number;
|
46 | scrollWidth: number;
|
47 | };
|
48 |
|
49 |
|
50 |
|
51 |
|
52 | export class ScrollSync extends PureComponent<ScrollSyncProps, ScrollSyncState> {
|
53 | static propTypes: {
|
54 | children: PropTypes.Validator<(props: ScrollSyncChildProps) => React.ReactNode>;
|
55 | };
|
56 | }
|
57 |
|
58 | export default ScrollSync;
|