UNPKG

1.72 kBTypeScriptView Raw
1import * as React from 'react';
2import { ConfigConsumerProps } from '../config-provider';
3export interface AffixProps {
4 /** 距离窗口顶部达到指定偏移量后触发 */
5 offsetTop?: number;
6 /** 距离窗口底部达到指定偏移量后触发 */
7 offsetBottom?: number;
8 style?: React.CSSProperties;
9 /** 固定状态改变时触发的回调函数 */
10 onChange?: (affixed?: boolean) => void;
11 /** 设置 Affix 需要监听其滚动事件的元素,值为一个返回对应 DOM 元素的函数 */
12 target?: () => Window | HTMLElement | null;
13 prefixCls?: string;
14 className?: string;
15 children: React.ReactNode;
16}
17declare enum AffixStatus {
18 None = 0,
19 Prepare = 1
20}
21export interface AffixState {
22 affixStyle?: React.CSSProperties;
23 placeholderStyle?: React.CSSProperties;
24 status: AffixStatus;
25 lastAffix: boolean;
26 prevTarget: Window | HTMLElement | null;
27}
28declare class Affix extends React.Component<AffixProps, AffixState> {
29 static contextType: React.Context<ConfigConsumerProps>;
30 state: AffixState;
31 placeholderNode: HTMLDivElement;
32 fixedNode: HTMLDivElement;
33 private timeout;
34 context: ConfigConsumerProps;
35 private getTargetFunc;
36 componentDidMount(): void;
37 componentDidUpdate(prevProps: AffixProps): void;
38 componentWillUnmount(): void;
39 getOffsetTop: () => number | undefined;
40 getOffsetBottom: () => number | undefined;
41 savePlaceholderNode: (node: HTMLDivElement) => void;
42 saveFixedNode: (node: HTMLDivElement) => void;
43 measure: () => void;
44 prepareMeasure: () => void;
45 updatePosition(): void;
46 lazyUpdatePosition(): void;
47 render: () => JSX.Element;
48}
49export default Affix;