mirror of
https://github.com/open-webui/open-webui
synced 2025-01-09 20:44:30 +00:00
31 lines
669 B
Svelte
31 lines
669 B
Svelte
|
<script lang="ts">
|
||
|
import { createEventDispatcher, onMount } from 'svelte';
|
||
|
const dispatch = createEventDispatcher();
|
||
|
|
||
|
let loaderElement: HTMLElement;
|
||
|
|
||
|
onMount(() => {
|
||
|
const observer = new IntersectionObserver(
|
||
|
(entries, observer) => {
|
||
|
entries.forEach((entry) => {
|
||
|
if (entry.isIntersecting) {
|
||
|
dispatch('visible');
|
||
|
// observer.unobserve(loaderElement); // Stop observing until content is loaded
|
||
|
}
|
||
|
});
|
||
|
},
|
||
|
{
|
||
|
root: null, // viewport
|
||
|
rootMargin: '0px',
|
||
|
threshold: 1.0 // When 100% of the loader is visible
|
||
|
}
|
||
|
);
|
||
|
|
||
|
observer.observe(loaderElement);
|
||
|
});
|
||
|
</script>
|
||
|
|
||
|
<div bind:this={loaderElement}>
|
||
|
<slot />
|
||
|
</div>
|