Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | <script lang="ts">
import { getRootObserver, type RootObserver } from "./observe";
import { setContext } from "svelte";
import key from "./key";
import { browser } from "$app/environment";
type RootOption = Element | undefined;
export let root: RootOption | Promise<RootOption> = undefined;
export let rootMargin: string | undefined = undefined;
export let enabled = true;
const getRootObserverPromise = async (): Promise<RootObserver | undefined> => {
if (!browser) return undefined;
if (!root) return getRootObserver({ rootMargin });
if (root instanceof Element) return getRootObserver({ root, rootMargin });
if (root instanceof Promise) return getRootObserver({ root: await root, rootMargin });
};
if (enabled && browser) {
setContext<Promise<RootObserver | undefined>>(key, getRootObserverPromise());
}
</script>
<slot />
|