@combine-labs/combine-polaris
Version:
Combine Lab's product component library. Forked from Shopify's Polaris.
34 lines (33 loc) • 1.25 kB
TypeScript
export interface StickyItem {
/** Node of the sticky element */
stickyNode: HTMLElement;
/** Placeholder element */
placeHolderNode: HTMLElement;
/** Element outlining the fixed position boundaries */
boundingElement: HTMLElement | null;
/** Offset vertical spacing from the top of the scrollable container */
offset: boolean;
/** Should the element remain in a fixed position when the layout is stacked (smaller screens) */
disableWhenStacked: boolean;
/** Method to handle positioning */
handlePositioning(stick: boolean, top?: number, left?: number, width?: string | number): void;
}
export default class StickyManager {
private stickyItems;
private stuckItems;
private container;
constructor(container?: Document | HTMLElement);
registerStickyItem(stickyItem: StickyItem): void;
unregisterStickyItem(nodeToRemove: HTMLElement): void;
setContainer(el: Document | HTMLElement): void;
removeScrollListener(): void;
private handleResize;
private handleScroll;
private manageStickyItems;
private evaluateStickyItem;
private updateStuckItems;
private addStuckItem;
private removeStuckItem;
private getOffset;
private isNodeStuck;
}