UNPKG

typeit

Version:

The most versatile animated typing utility on the planet.

16 lines (14 loc) 354 B
export default (element: HTMLElement, func: Function): void => { let observer = new IntersectionObserver( (entries, observer) => { entries.forEach((entry) => { if (entry.isIntersecting) { func(); observer.unobserve(element); } }); }, { threshold: 1.0 }, ); observer.observe(element); };