mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-06-10 15:03:32 -07:00
21 lines
419 B
JavaScript
21 lines
419 B
JavaScript
/**
|
|
* @param {Element} element
|
|
* @param {{ show: () => void, hide: () => void }} lifecycle
|
|
*/
|
|
export function onChartVisibility(element, lifecycle) {
|
|
const observer = new IntersectionObserver(
|
|
(entries) => {
|
|
if (entries[0].isIntersecting) {
|
|
lifecycle.show();
|
|
} else {
|
|
lifecycle.hide();
|
|
}
|
|
},
|
|
{
|
|
rootMargin: "800px 0px",
|
|
},
|
|
);
|
|
|
|
observer.observe(element);
|
|
}
|