-
Notifications
You must be signed in to change notification settings - Fork 8
/
index.d.ts
153 lines (125 loc) · 3.17 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
// Type definitions for OdoAffix
// Project: odopod-code-library
// Definitions by: Glen Cheney <https://github.com/Vestride>
export as namespace OdoAffix;
export = OdoAffix;
declare class OdoAffix {
/**
* Create a new affix instance.
* @param {HTMLElement} element Main element which represents this class.
*/
constructor(element: HTMLElement);
/** Main element for this class */
element: HTMLElement;
/**
* Whether the main element is position fixed.
* @type {boolean}
*/
isStuck: boolean;
/**
* Whether the main element is stuck to the bottom of its container.
* @type {boolean}
*/
isAtBottom: boolean;
/**
* Whether the main element has been promoted to its own layer for the GPU.
* @type {boolean}
* @protected
*/
protected isPromoted: boolean;
/**
* Cache values so they don't need to be queried on scroll.
*/
protected read(): void;
/**
* Set styles.
*/
protected write(): void;
/**
* This method runs on every frame to update the placement of the sticky element.
* @param {number} scrollTop Scroll top of the page.
*/
process(scrollTop?: number): void;
/**
* Whether the browser's scroll position is within promotion range.
*/
isInPromotionRange(scrollTop: number): boolean;
protected stick(): void;
protected stickToBottom(): void;
protected unstick(): void;
/**
* Add styles which will put the affix-element in a new layer.
* @protected
*/
protected layerPromote(): void;
/**
* Remove styles which cause layer promotion.
* @protected
*/
protected layerDemote(): void;
/**
* Reset values that are set with `write` so that they can be read again.
* @protected
*/
protected reset(): void;
/**
* Define a custom getter to determine overlap.
*/
uiOverlap: () => number;
/**
* The offset when this component becomes sticky.
*/
readonly top: number;
/**
* The offset when this component sticks to the bottom if its container.
*/
readonly bottom: number;
/**
* Reset everything, cache offsets, and recalculate.
*/
update(): void;
/**
* Close the affix, remove event listeners and element references.
*/
dispose(): void;
}
declare namespace OdoAffix {
/**
* Batch update all instances. This method is more efficient because it syncs
* reads and writes to the DOM for each instance.
*/
function update(): void;
/**
* Remove an item from an array.
* @param {any[]} arr Array to use.
* @param {any} item Item to remove.
* @return {any} Item removed.
*/
function arrayRemove(arr: any[], item: any): any;
/**
* Array of affix instances.
* @type {OdoAffix[]}
*/
const instances: OdoAffix[];
/**
* HTML class names for elements of the affix.
*/
enum Classes {
BASE = 'odo-affix',
AT_TOP = 'odo-affix--at-top',
AT_BOTTOM = 'odo-affix--at-bottom',
}
/**
* Range in pixels before and after the affix point that the element-to-be-affixed
* should be layer-promoted.
*/
const PROMOTION_RANGE: number;
/**
* Height of the page.
*/
const documentHeight: number;
/**
* Height of the viewport.
*/
const viewportHeight: number;
}