mirror of
https://github.com/open-webui/open-webui
synced 2025-06-26 18:26:48 +00:00
enh: infinite scroll messages
This commit is contained in:
@@ -1,16 +1,24 @@
|
||||
<script lang="ts">
|
||||
import { createEventDispatcher, onMount } from 'svelte';
|
||||
import { createEventDispatcher, onDestroy, onMount } from 'svelte';
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
let loaderElement: HTMLElement;
|
||||
|
||||
let observer;
|
||||
let intervalId;
|
||||
|
||||
onMount(() => {
|
||||
const observer = new IntersectionObserver(
|
||||
observer = new IntersectionObserver(
|
||||
(entries, observer) => {
|
||||
entries.forEach((entry) => {
|
||||
if (entry.isIntersecting) {
|
||||
dispatch('visible');
|
||||
intervalId = setInterval(() => {
|
||||
dispatch('visible');
|
||||
}, 100);
|
||||
// dispatch('visible');
|
||||
// observer.unobserve(loaderElement); // Stop observing until content is loaded
|
||||
} else {
|
||||
clearInterval(intervalId);
|
||||
}
|
||||
});
|
||||
},
|
||||
@@ -23,6 +31,14 @@
|
||||
|
||||
observer.observe(loaderElement);
|
||||
});
|
||||
|
||||
onDestroy(() => {
|
||||
observer.disconnect();
|
||||
|
||||
if (intervalId) {
|
||||
clearInterval(intervalId);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<div bind:this={loaderElement}>
|
||||
|
||||
Reference in New Issue
Block a user