Skip to content

Instantly share code, notes, and snippets.

@ddprrt
Last active July 16, 2020 13:56
Show Gist options
  • Save ddprrt/4b7c370f72908fe84a2afbe81681d91a to your computer and use it in GitHub Desktop.
Save ddprrt/4b7c370f72908fe84a2afbe81681d91a to your computer and use it in GitHub Desktop.
Resize Observer IDL
type ResizeObserverBoxOptions = "border-box" | "content-box" | "device-pixel-content-box";
interface ResizeObserverOptions {
box?: ResizeObserverBoxOptions;
}
interface ResizeObservation {
readonly lastReportedSizes: ReadonlyArray<ResizeObserverSize>;
readonly observedBox: ResizeObserverBoxOptions;
readonly target: Element;
}
declare var ResizeObservation: {
prototype: ResizeObservation;
new(target: Element): ResizeObservation;
};
interface ResizeObserver {
disconnect(): void;
observe(target: Element, options?: ResizeObserverOptions): void;
unobserve(target: Element): void;
}
declare var ResizeObserver: {
prototype: ResizeObserver;
new(callback: ResizeObserverCallback): ResizeObserver;
};
interface ResizeObserverEntry {
readonly borderBoxSize: ReadonlyArray<ResizeObserverSize>;
readonly contentBoxSize: ReadonlyArray<ResizeObserverSize>;
readonly contentRect: DOMRectReadOnly;
readonly devicePixelContentBoxSize: ReadonlyArray<ResizeObserverSize>;
readonly target: Element;
}
declare var ResizeObserverEntry: {
prototype: ResizeObserverEntry;
new(): ResizeObserverEntry;
};
interface ResizeObserverSize {
readonly blockSize: number;
readonly inlineSize: number;
}
declare var ResizeObserverSize: {
prototype: ResizeObserverSize;
new(): ResizeObserverSize;
};
interface ResizeObserverCallback {
(entries: ResizeObserverEntry[], observer: ResizeObserver): void;
}
enum ResizeObserverBoxOptions {
"border-box", "content-box", "device-pixel-content-box"
};
dictionary ResizeObserverOptions {
ResizeObserverBoxOptions box = "content-box";
};
[Exposed=(Window)]
interface ResizeObserver {
constructor(ResizeObserverCallback callback);
void observe(Element target, optional ResizeObserverOptions options);
void unobserve(Element target);
void disconnect();
};
callback ResizeObserverCallback = void (sequence<ResizeObserverEntry> entries, ResizeObserver observer);
[Exposed=Window]
interface ResizeObserverEntry {
readonly attribute Element target;
readonly attribute DOMRectReadOnly contentRect;
readonly attribute FrozenArray<ResizeObserverSize> borderBoxSize;
readonly attribute FrozenArray<ResizeObserverSize> contentBoxSize;
readonly attribute FrozenArray<ResizeObserverSize> devicePixelContentBoxSize;
};
interface ResizeObserverSize {
readonly attribute unrestricted double inlineSize;
readonly attribute unrestricted double blockSize;
};
interface ResizeObservation {
constructor(Element target);
readonly attribute Element target;
readonly attribute ResizeObserverBoxOptions observedBox;
readonly attribute FrozenArray<ResizeObserverSize> lastReportedSizes;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment