UNPKG

1.47 kBTypeScriptView Raw
1interface Window {
2 ResizeObserver: ResizeObserver
3}
4
5/**
6 * The ResizeObserver interface is used to observe changes to Element's content
7 * rect.
8 *
9 * It is modeled after MutationObserver and IntersectionObserver.
10 */
11interface ResizeObserver {
12 new (callback: ResizeObserverCallback)
13
14 /**
15 * Adds target to the list of observed elements.
16 */
17 observe: (target: Element) => void
18
19 /**
20 * Removes target from the list of observed elements.
21 */
22 unobserve: (target: Element) => void
23
24 /**
25 * Clears both the observationTargets and activeTargets lists.
26 */
27 disconnect: () => void
28}
29
30/**
31 * This callback delivers ResizeObserver's notifications. It is invoked by a
32 * broadcast active observations algorithm.
33 */
34interface ResizeObserverCallback {
35 (entries: ResizeObserverEntry[], observer: ResizeObserver): void
36}
37
38interface ResizeObserverEntry {
39 /**
40 * @param target The Element whose size has changed.
41 */
42 new (target: Element)
43
44 /**
45 * The Element whose size has changed.
46 */
47 readonly target: Element
48
49 /**
50 * Element's content rect when ResizeObserverCallback is invoked.
51 */
52 readonly contentRect: DOMRectReadOnly
53}
54
55interface DOMRectReadOnly {
56 fromRect(other: DOMRectInit | undefined): DOMRectReadOnly
57
58 readonly x: number
59 readonly y: number
60 readonly width: number
61 readonly height: number
62 readonly top: number
63 readonly right: number
64 readonly bottom: number
65 readonly left: number
66
67 toJSON: () => any
68}