From f47527e584edb294cad608100bba8a2ae54424a6 Mon Sep 17 00:00:00 2001 From: Hakadao Date: Tue, 28 May 2024 01:52:04 +0800 Subject: [PATCH] refactor: Add throttling to handle reach bottom event --- src/contentScripts/views/App.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/contentScripts/views/App.vue b/src/contentScripts/views/App.vue index 476f19a5..1405bdd6 100644 --- a/src/contentScripts/views/App.vue +++ b/src/contentScripts/views/App.vue @@ -35,6 +35,7 @@ const showTopBarMask = ref(false) const handlePageRefresh = ref<() => void>() const handleReachBottom = ref<() => void>() const handleThrottledPageRefresh = useThrottleFn(() => handlePageRefresh.value?.(), 500) +const handleThrottledReachBottom = useThrottleFn(() => handleReachBottom.value?.(), 500) const handleThrottledBackToTop = useThrottleFn(() => handleBackToTop(), 1000) const topBarRef = ref() const reachTop = ref(false) @@ -220,7 +221,7 @@ function handleOsScroll() { } if (clientHeight + scrollTop >= scrollHeight - 150) - handleReachBottom.value?.() + handleThrottledReachBottom() if (isHomePage()) topBarRef.value?.handleScroll()