Files
classroomio/apps/dashboard/src/lib/features/ui/course-landing-page/components/IntersectionObserver.ts
T

20 lines
389 B
TypeScript
Raw Normal View History

export function observeIntersection(node, callback, options = {}) {
const observer = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
callback(true);
} else {
callback(false);
}
});
}, options);
observer.observe(node);
return {
destroy() {
observer.unobserve(node);
}
};
}