mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-04 15:53:40 -07:00
website_next: snapshot
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
const lifecycleByElement = new WeakMap();
|
||||
const observer = new IntersectionObserver(
|
||||
(entries) => {
|
||||
for (const entry of entries) {
|
||||
const lifecycle = lifecycleByElement.get(entry.target);
|
||||
lifecycle?.[entry.isIntersecting ? "show" : "hide"]();
|
||||
}
|
||||
},
|
||||
{
|
||||
rootMargin: "400px 0px",
|
||||
},
|
||||
);
|
||||
|
||||
/**
|
||||
* @param {Element} element
|
||||
* @param {{ show: () => void, hide: () => void }} lifecycle
|
||||
*/
|
||||
export function onChartVisibility(element, lifecycle) {
|
||||
lifecycleByElement.set(element, lifecycle);
|
||||
observer.observe(element);
|
||||
}
|
||||
Reference in New Issue
Block a user