17 lines
477 B
TypeScript
17 lines
477 B
TypeScript
export interface IntersectionObserverOptions {
|
|
threshold?: number;
|
|
rootMargin?: string;
|
|
}
|
|
|
|
export const createIntersectionObserver = (
|
|
callback: IntersectionObserverCallback,
|
|
options: IntersectionObserverOptions = {}
|
|
): IntersectionObserver => {
|
|
const defaultOptions: IntersectionObserverOptions = {
|
|
threshold: 0.3,
|
|
rootMargin: '0px 0px -50px 0px'
|
|
};
|
|
|
|
return new IntersectionObserver(callback, { ...defaultOptions, ...options });
|
|
};
|