UNPKG

baseframe-js

Version:

A suite of useful Javascript plugins and functions to help with Front-end Development on websites

39 lines (38 loc) 1.33 kB
import type { Cash, Selector } from "cash-dom"; import type { LocationHashTracking, StringPluginArgChoices } from './types'; export interface IScrollSpyDefaults extends LocationHashTracking { observerOptions: IntersectionObserverInit; cssPrefix: string; spyNavElems: 'a' | 'button'; setActiveCssToLi: boolean; spyBody: Selector; spyElems: string; callback?: ScrollSpyCallBack; } export interface IScrollSpyOptions extends Partial<IScrollSpyDefaults> { spyBody: Selector; } type ScrollSpyCallBack = (topMostEntries: HTMLElement[], navEntries: HTMLElement[]) => void; export default class ScrollSpy { #private; inViewEntries: Set<HTMLElement>; backUpInViewEntry: HTMLElement; params: IScrollSpyOptions; element: HTMLElement; $spyBody: Cash; spyContents: HTMLElement[]; static defaults: IScrollSpyOptions; static version: string; static pluginName: string; constructor(element: HTMLElement, options: IScrollSpyOptions); handleEvents(): void; scrollToElement(elemId: string, behavior: ScrollOptions["behavior"]): Cash; loadFromUrl(): void; static remove(element: Cash, plugin?: ScrollSpy): void; } declare module 'cash-dom' { interface Cash { scrollSpy(options?: IScrollSpyOptions | StringPluginArgChoices): Cash; } } export {};