import { Rect } from 'spase'; import { DirtyType, EventType } from '../enums/index.js'; import { DirtyInfo, DirtyTarget } from '../types/index.js'; /** * Delegate for managing update calls of an object. */ export declare class UpdateDelegate { /** * Default refresh (debounce) rate in milliseconds. */ protected static DEFAULT_REFRESH_RATE: number; protected static DEFAULT_DIRTY_INFO: DirtyInfo; protected dirtyInfo: DirtyInfo; protected eventTargetDict: Partial>; protected eventHandlerDict: Partial>; /** * Handler invoked whenever the {@link UpdateDelegate} emits an update event. * * @param info An object describing what information was dirty since the last * invocation of this handler. * @param delegate The {@link UpdateDelegate} that invoked this handler. */ protected updateHandler?: (info: DirtyInfo, delegate: UpdateDelegate) => void; /** * Animation frame tracker. */ private pendingAnimationFrame?; /** * Cache. */ private dirtyTable; private responsivenessTable?; private eventPropDict; /** * Creates a new {@link UpdateDelegate} instance. * * @param updateHandler The handler to invoke upon every update event. * @param descriptors Map of responsive descriptors. */ constructor(updateHandler: (info: DirtyInfo, delegate: UpdateDelegate) => void, descriptors?: Partial>); /** * Gets the current viewport {@link Rect} of the window. * * @returns Viewport {@link Rect}. */ get viewport(): Rect; /** * Initiates the update delegation process. */ init(): void; /** * Destroys all resources allocated by this {@link UpdateDelegate} instance. */ deinit(): void; /** * Checks dirty status of a given dirty type. * * @param dirtyType Dirty type. * * @returns `true` if dirty, `false` otherwise. */ isDirty(dirtyType: DirtyType): boolean; /** * Sets a dirty type as dirty, consequently invoking an update on the next * animation frame. * * @param dirtyType The dirty type to set. * @param validateNow Determines if the update should be validated right away * instead of on the next animation frame. */ setDirty(dirtyType: DirtyType, validateNow?: boolean): void; /** * Gets the dirty target element based on its descriptor. * * @param descriptor The descriptor. * * @returns The dirty target if it exists. */ protected getDirtyTarget(descriptor: DirtyTarget): Window | HTMLElement | undefined | null; /** * Updates the dirty info for position. * * @param reference The reference element. */ protected updatePositionInfo(reference?: DirtyTarget): void; /** * Updates the dirty info for size. */ protected updateSizeInfo(): void; /** * Sets up the responsiveness to the provided target. Only the following event * types support a custom target, the rest use window as the target: * 1. 'scroll' * 2. 'wheel' * 3. 'mousemove' * * @param params @see ResponsiveDescriptor */ private initResponsiveness; /** * Handler invoked whenever a visual update is required. */ private update; /** * Handler invoked when the window resizes. * * @param event The dispatched event. */ private onWindowResize; /** * Handler invoked when the target resize check interval is triggered. */ private onResize; /** * Handler invoked when the window scrolls. * * @param event The dispatched event. */ private onScroll; /** * Handler invoked when the mouse is moved in the window. * * @param event The dispatched event. */ private onWindowMouseMove; /** * Handler invoked when the mouse wheel is spinning. * * @param event The dispatched event. */ private onWindowMouseWheel; /** * Handler invoked when the window orientation changes. * * @param event = The dispatched event. */ private onWindowOrientationChange; /** * Handler invoked when there is a key up event. * * @param event The dispatched event. */ private onWindowKeyUp; /** * Handler invoked when there is a key down event. * * @param event The dispatched event. */ private onWindowKeyDown; /** * Handler invoked when there is a key press event. * * @param event The dispatched event. */ private onWindowKeyPress; /** * Handler invoked when the enter frame check interval is triggered. */ private onEnterFrame; }