Skip to content

Commit

Permalink
docs: add docs for RO interface
Browse files Browse the repository at this point in the history
  • Loading branch information
TremayneChrist committed Jul 31, 2021
1 parent 5602cc3 commit 1efb026
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/ResizeObserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import { ResizeObserverOptions } from './ResizeObserverOptions';
import { isElement } from './utils/element';

/**
* The ResizeObserver API is an interface for observing changes to Element’s size.
* It is an Element's counterpart to window.resize event.
*
* https://drafts.csswg.org/resize-observer-1/#resize-observer-interface
*/
class ResizeObserver {
Expand All @@ -18,6 +21,13 @@ class ResizeObserver {
ResizeObserverController.connect(this, callback);
}

/**
* Observes an element,
* notifying the handler of the current and subsequent sizes.
* @param target Element to observe
* @param options Options to pass to the observer
* @returns {void}
*/
public observe (target: Element, options?: ResizeObserverOptions): void {
if (arguments.length === 0) {
throw new TypeError(`Failed to execute 'observe' on 'ResizeObserver': 1 argument required, but only 0 present.`)
Expand All @@ -28,6 +38,11 @@ class ResizeObserver {
ResizeObserverController.observe(this, target, options);
}

/**
* Stops observing the element for any further changes.
* @param target Element to stop observing
* @returns {void}
*/
public unobserve (target: Element): void {
if (arguments.length === 0) {
throw new TypeError(`Failed to execute 'unobserve' on 'ResizeObserver': 1 argument required, but only 0 present.`)
Expand All @@ -38,10 +53,17 @@ class ResizeObserver {
ResizeObserverController.unobserve(this, target);
}

/**
* Disconnects all observed targets.
* @returns {void}
*/
public disconnect (): void {
ResizeObserverController.disconnect(this);
}

/**
* @override
*/
public static toString (): string {
return 'function ResizeObserver () { [polyfill code] }';
}
Expand Down

0 comments on commit 1efb026

Please sign in to comment.