gpu-curtains
Version:
gpu-curtains is a 3D WebGPU rendering engine. It can be used as a standalone 3D engine, but also includes extra classes focused on mapping 3d objects to DOM elements; It allows users to synchronize values such as position, sizing, or scale between them.
49 lines (48 loc) • 1.75 kB
TypeScript
import { DOMElement } from '../core/DOM/DOMElement';
/**
* Defines a {@link ResizeManager} entry
*/
export interface ResizeManagerEntry {
/** {@link HTMLElement} to track */
element: DOMElement['element'] | Element;
/** Priority in which to call the callback function */
priority?: number;
/** Function to execute when the {@link element} is resized */
callback: () => void | null;
}
/**
* Tiny wrapper around {@link ResizeObserver} used to execute callbacks when given {@link HTMLElement} size changes.
*/
export declare class ResizeManager {
/** Whether we should add elements to our {@link resizeObserver} or not */
shouldWatch: boolean;
/** Array of {@link ResizeManagerEntry | entries} */
entries: ResizeManagerEntry[];
/** {@link ResizeObserver} used */
resizeObserver: ResizeObserver | undefined;
/**
* ResizeManager constructor
*/
constructor();
/**
* Set {@link ResizeManager.shouldWatch | shouldWatch}.
* @param shouldWatch - whether to watch or not.
*/
useObserver(shouldWatch?: boolean): void;
/**
* Track an {@link HTMLElement} size change and execute a callback function when it happens.
* @param entry - {@link ResizeManagerEntry | entry} to watch.
*/
observe({ element, priority, callback }: ResizeManagerEntry): void;
/**
* Unobserve an {@link HTMLElement} and remove it from our {@link entries} array.
* @param element - {@link HTMLElement} to unobserve.
*/
unobserve(element: DOMElement['element'] | Element): void;
/**
* Destroy our {@link ResizeManager}.
*/
destroy(): void;
}
/** The {@link ResizeManager} instance. */
export declare const resizeManager: ResizeManager;