From 3f2469ea411e4268d63d3c20f5567163e98372ca Mon Sep 17 00:00:00 2001 From: DebugIsFalse <511418503@qq.com> Date: Tue, 21 May 2024 11:57:22 +0800 Subject: [PATCH] fix: bebounce --- components/i/md/mdc.vue | 9 ++++++++- pages/search/[id].vue | 18 +++++++++--------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/components/i/md/mdc.vue b/components/i/md/mdc.vue index 98645b8..86f8d12 100644 --- a/components/i/md/mdc.vue +++ b/components/i/md/mdc.vue @@ -1,8 +1,15 @@ \ No newline at end of file diff --git a/pages/search/[id].vue b/pages/search/[id].vue index 3ef0fd2..37770be 100644 --- a/pages/search/[id].vue +++ b/pages/search/[id].vue @@ -175,17 +175,17 @@ useHead({ // 是否停止自动滚动到底部 const isAutoToBottom = ref(true) let markedWindowScrollTop = 0 -const handleScroll = () => { +const handleScroll = (event, params) => { // 在asking操作的时候生效 if (!asking.value || !isAutoToBottom.value) return - const offsetValue = 5; - const top = window.scrollY; - // console.log(`top + offsetValue:`, top, markedWindowScrollTop, top < markedWindowScrollTop) - if (top < markedWindowScrollTop) { - isAutoToBottom.value = false - } else { - markedWindowScrollTop = top - } + nextTick(() => { + const top = window.scrollY; + if (top < y.value) { + isAutoToBottom.value = false + } else { + markedWindowScrollTop = top + } + }) } const scrollToView = () => { if (!isAutoToBottom.value) return -- GitLab