mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-06-21 03:58:24 -07:00
website: redesign part 13
This commit is contained in:
@@ -1,14 +1,20 @@
|
||||
/**
|
||||
* @param {Element} element
|
||||
* @param {() => void} callback
|
||||
* @param {{ show: () => void, hide: () => void }} lifecycle
|
||||
*/
|
||||
export function onFirstIntersection(element, callback) {
|
||||
const observer = new IntersectionObserver((entries) => {
|
||||
if (!entries[0].isIntersecting) return;
|
||||
|
||||
observer.disconnect();
|
||||
callback();
|
||||
});
|
||||
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user