From b391ca37ab835a94c137f543a7374c72ef03e088 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 22 Sep 2023 13:51:08 +0200 Subject: [PATCH] Infinite scroll --- .../bbui/src/Form/Core/Multiselect.svelte | 1 + packages/bbui/src/Form/Core/Picker.svelte | 20 +++++++++++++++++-- packages/bbui/src/Form/Core/Select.svelte | 1 + .../app/forms/RelationshipField.svelte | 7 +++++++ 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/packages/bbui/src/Form/Core/Multiselect.svelte b/packages/bbui/src/Form/Core/Multiselect.svelte index bd1b7dfd2c..4d7b7537c9 100644 --- a/packages/bbui/src/Form/Core/Multiselect.svelte +++ b/packages/bbui/src/Form/Core/Multiselect.svelte @@ -82,6 +82,7 @@ { + const scrollPxThreshold = 100 + const scrollPositionFromBottom = + e.target.scrollHeight - e.target.clientHeight - e.target.scrollTop + if (scrollPositionFromBottom < scrollPxThreshold) { + dispatch("loadMore") + } + } + + $: component?.addEventListener("scroll", onScroll) + onDestroy(() => { + component?.removeEventListener("scroll", null) + })