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.
50 lines (49 loc) • 2 kB
TypeScript
import { DOMPosition } from '../core/DOM/DOMElement';
/**
* Parameters used to create a {@link ScrollManager}
*/
export interface ScrollManagerParams {
/** Current scroll position */
scroll?: DOMPosition;
/** Last scroll deltas */
delta?: DOMPosition;
/** Whether the {@link ScrollManager} should listen to the window scroll event or not */
shouldWatch?: boolean;
/** Callback to execute each time the {@link ScrollManager#scroll | scroll} values change */
onScroll?: (delta?: DOMPosition) => void;
}
/**
* Used to keep track of our scroll position, scroll deltas and trigger an onScroll callback.<br>
* Could either listen to the native scroll event or be hooked to any scroll (natural or virtual) scroll event
*/
export declare class ScrollManager {
#private;
/** Current scroll position */
scroll: DOMPosition;
/** Last scroll deltas */
delta: DOMPosition;
/** Whether the {@link ScrollManager} should listen to the window scroll event or not */
shouldWatch: boolean;
/** Callback to execute each time the {@link scroll} values change */
onScroll: (delta?: DOMPosition) => void;
/**
* ScrollManager constructor
* @param parameters - {@link ScrollManagerParams | parameters} used to create this {@link ScrollManager}
*/
constructor({ scroll, delta, shouldWatch, onScroll, }?: ScrollManagerParams);
/**
* Called by the scroll event listener
*/
setScroll(): void;
/**
* Updates the scroll manager X and Y scroll values as well as last X and Y deltas
* Internally called by the scroll event listener
* Could be called externally as well if the user wants to handle the scroll by himself
* @param parameters - {@link core/DOM/DOMElement.DOMPosition | scroll values}
*/
updateScrollValues({ x, y }: DOMPosition): void;
/**
* Destroy our scroll manager (just remove our event listner if it had been added previously)
*/
destroy(): void;
}