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