Skip to content

Commit 441a645

Browse files
authored
Merge pull request #657 from saschanaz/intersection
Update Intersection Observer types
2 parents 921ba4b + ab48d38 commit 441a645

3 files changed

Lines changed: 48 additions & 3 deletions

File tree

baselines/dom.generated.d.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -539,9 +539,10 @@ interface IIRFilterOptions extends AudioNodeOptions {
539539

540540
interface IntersectionObserverEntryInit {
541541
boundingClientRect: DOMRectInit;
542+
intersectionRatio: number;
542543
intersectionRect: DOMRectInit;
543544
isIntersecting: boolean;
544-
rootBounds: DOMRectInit;
545+
rootBounds: DOMRectInit | null;
545546
target: Element;
546547
time: number;
547548
}
@@ -9399,7 +9400,7 @@ declare var ImageData: {
93999400
interface IntersectionObserver {
94009401
readonly root: Element | null;
94019402
readonly rootMargin: string;
9402-
readonly thresholds: number[];
9403+
readonly thresholds: ReadonlyArray<number>;
94039404
disconnect(): void;
94049405
observe(target: Element): void;
94059406
takeRecords(): IntersectionObserverEntry[];
@@ -9417,7 +9418,7 @@ interface IntersectionObserverEntry {
94179418
readonly intersectionRatio: number;
94189419
readonly intersectionRect: ClientRect | DOMRect;
94199420
readonly isIntersecting: boolean;
9420-
readonly rootBounds: ClientRect | DOMRect;
9421+
readonly rootBounds: ClientRect | DOMRect | null;
94219422
readonly target: Element;
94229423
readonly time: number;
94239424
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
callback IntersectionObserverCallback = void (sequence<IntersectionObserverEntry> entries, IntersectionObserver observer);
2+
3+
[Constructor(IntersectionObserverCallback callback, optional IntersectionObserverInit options),
4+
Exposed=Window]
5+
interface IntersectionObserver {
6+
readonly attribute Element? root;
7+
readonly attribute DOMString rootMargin;
8+
readonly attribute FrozenArray<double> thresholds;
9+
void observe(Element target);
10+
void unobserve(Element target);
11+
void disconnect();
12+
sequence<IntersectionObserverEntry> takeRecords();
13+
};
14+
15+
[Constructor(IntersectionObserverEntryInit intersectionObserverEntryInit)]
16+
interface IntersectionObserverEntry {
17+
readonly attribute DOMHighResTimeStamp time;
18+
readonly attribute DOMRectReadOnly? rootBounds;
19+
readonly attribute DOMRectReadOnly boundingClientRect;
20+
readonly attribute DOMRectReadOnly intersectionRect;
21+
readonly attribute boolean isIntersecting;
22+
readonly attribute double intersectionRatio;
23+
readonly attribute Element target;
24+
};
25+
26+
dictionary IntersectionObserverEntryInit {
27+
required DOMHighResTimeStamp time;
28+
required DOMRectInit? rootBounds;
29+
required DOMRectInit boundingClientRect;
30+
required DOMRectInit intersectionRect;
31+
required boolean isIntersecting;
32+
required double intersectionRatio;
33+
required Element target;
34+
};
35+
36+
dictionary IntersectionObserverInit {
37+
Element? root = null;
38+
DOMString rootMargin = "0px";
39+
(double or sequence<double>) threshold = 0;
40+
};

inputfiles/idlSources.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,10 @@
210210
"url": "https://www.w3.org/TR/IndexedDB-2/",
211211
"title": "Indexed Database"
212212
},
213+
{
214+
"url": "https://www.w3.org/TR/intersection-observer/",
215+
"title": "Intersection Observer"
216+
},
213217
{
214218
"url": "https://www.w3.org/TR/media-source/",
215219
"title": "Media Source Extensions"

0 commit comments

Comments
 (0)