mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-06-12 07:53:32 -07:00
15 lines
310 B
JavaScript
15 lines
310 B
JavaScript
/**
|
|
* @param {Element} element
|
|
* @param {() => void} callback
|
|
*/
|
|
export function onFirstIntersection(element, callback) {
|
|
const observer = new IntersectionObserver((entries) => {
|
|
if (!entries[0].isIntersecting) return;
|
|
|
|
observer.disconnect();
|
|
callback();
|
|
});
|
|
|
|
observer.observe(element);
|
|
}
|