Files
DredgeTours/resources/js/composables/useIntersectionObserver.ts
2025-09-16 22:01:42 +10:00

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 });
};