UNPKG

baseframe-js

Version:

Baseframe JS is a comprehensive suite of modular plugins and utilities designed for front-end development

41 lines (40 loc) 1.47 kB
import type { LocationTracking, StringPluginArgChoices } from './types'; import { type BaseElem, type SelectorRoot } from "base-elem-js"; export interface IScrollSpyDefaults extends LocationTracking { observerOptions: IntersectionObserverInit; cssPrefix: string; spyNavElems: 'a' | 'button'; setActiveCssToLi: boolean; scrollBehavior: ScrollOptions["behavior"]; scrollDuration: number; spyBody: SelectorRoot | string; spyElems: string; callback?: ScrollSpyCallBack; } export interface IScrollSpyOptions extends Partial<IScrollSpyDefaults> { spyBody: SelectorRoot | string; } type ScrollSpyCallBack = (topMostEntries: HTMLElement[], navEntries: HTMLElement[]) => void; export default class ScrollSpy { #private; inViewEntries: Set<HTMLElement>; backUpInViewEntry: HTMLElement; params: IScrollSpyOptions; element: HTMLElement; $spyBody: BaseElem; spyContents: HTMLElement[]; static defaults: IScrollSpyOptions; static version: string; static pluginName: string; constructor(element: HTMLElement, options: IScrollSpyOptions); scrollToElement(elemId: string, behavior: ScrollOptions["behavior"]): BaseElem; static remove(element: BaseElem, plugin?: ScrollSpy): void; } export interface ScrollSpyPlugin { scrollSpy(options?: IScrollSpyOptions | StringPluginArgChoices): BaseElem; } declare module 'base-elem-js' { interface BaseElem extends ScrollSpyPlugin { } } export {};