Files
radicle-explorer/explorer/src/components/Observer.svelte
T
Rūdolfs Ošiņš e37521c739 Move explorer into explorer/
Makes explorer and desktop sibling projects, as proposed in ADR 1.
This commit only moves files; paths in CI, scripts and docs are fixed
in the following commits.
2026-10-22 11:06:33 +02:00

43 lines
965 B
Svelte

<script lang="ts" context="module">
export function intersection(
node: HTMLElement,
observer: IntersectionObserver | undefined,
) {
if (!observer) return;
observer.observe(node);
return {
destroy() {
observer.unobserve(node);
},
};
}
</script>
<script lang="ts">
import { onDestroy } from "svelte";
let observer: IntersectionObserver | undefined = undefined;
// eslint-disable-next-line svelte/prefer-svelte-reactivity
let filesVisibility = new Set<string>();
if ("IntersectionObserver" in window) {
observer = new IntersectionObserver(entries => {
entries.forEach(entry => {
if (entry.isIntersecting) {
filesVisibility = filesVisibility.add(
entry.target.id.replace("observer:", ""),
);
}
});
});
}
onDestroy(() => {
if (observer) {
observer.disconnect();
}
});
</script>
<slot {observer} {filesVisibility} />