/
interfaces.ts
86 lines (72 loc) · 2.27 KB
/
interfaces.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
/*
Copyright 2016 LinkedIn Corp. Licensed under the Apache License,
Version 2.0 (the "License"); you may not use this file except in
compliance with the License. You may obtain a copy of the License
at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*/
export interface SpanielTrackedElement extends Element {
__spanielId: string;
}
export interface SpanielThreshold {
label: string;
ratio: number;
time?: number;
}
export interface SpanielObserverInit {
root?: SpanielTrackedElement;
rootMargin?: DOMString | DOMMargin; // default: 0px
threshold?: SpanielThreshold[]; // default: 0
}
export interface SpanielRecord {
target: SpanielTrackedElement;
payload: any;
thresholdStates: SpanielThresholdState[];
lastSeenEntry: IntersectionObserverEntry;
}
export interface SpanielThresholdState {
lastSatisfied: Boolean;
lastEntry: IntersectionObserverEntry;
threshold: SpanielThreshold;
lastVisible: number;
visible: boolean;
timeoutId?: number;
}
export interface SpanielIntersectionObserverEntryInit {
time: DOMHighResTimeStamp;
rootBounds: ClientRect;
boundingClientRect: ClientRect;
intersectionRect: ClientRect;
target: SpanielTrackedElement;
}
export interface SpanielObserverEntry extends IntersectionObserverEntryInit {
duration: number;
intersectionRatio: number;
entering: boolean;
label?: string;
payload?: any;
}
export interface IntersectionObserverClass {
new (callback: IntersectionObserverCallback, options?: IntersectionObserverInit): IntersectionObserver;
}
export interface SpanielObserverInterface {
disconnect: () => void;
unobserve: (element: SpanielTrackedElement) => void;
observe: (target: Element, payload: any) => string;
}
export type DOMString = string;
export type DOMHighResTimeStamp = number;
export interface DOMMargin {
top: number;
bottom: number;
left: number;
right: number;
}
export interface DOMRectReadOnly extends DOMRectInit, DOMMargin {}
export interface IntersectionObserverInit {
root?: SpanielTrackedElement;
rootMargin?: DOMString; // default: 0px
threshold?: number | number[]; // default: 0
}