wotsui-intersection-observer
Version:
Utility class based on Intersection Observer API
21 lines (20 loc) • 813 B
TypeScript
export interface IntersectionHandlerOptions {
threshold?: number;
observeOnce?: boolean;
toggleOpacity?: boolean;
intersectionClass?: string;
noIntersectionClass?: string;
intersectionHandler?: (entry: IntersectionObserverEntry) => any;
noIntersectionHandler?: (entry: IntersectionObserverEntry) => any;
}
export default class IntersectionHandler {
_observer: IntersectionObserver;
options: IntersectionHandlerOptions;
constructor(options: IntersectionHandlerOptions);
parseOptions(obj: {
[prop: string]: any;
}): IntersectionHandlerOptions;
observe(el: Element): void;
observerCallback(entries: IntersectionObserverEntry[], observer: IntersectionObserver): void;
applySettings(el: Element, isIntersecting: boolean): void;
}