@@ -90,7 +90,7 @@ const handleThrottledPageRefresh = useThrottleFn(() => {
9090 setTimeout (checkScrollComplete , 100 )
9191 }
9292}, 500 )
93- const handleThrottledReachBottom = useThrottleFn (() => handleReachBottom .value ?.(), 500 )
93+ const handleThrottledReachBottom = useThrottleFn (() => handleReachBottom .value ?.(), 200 )
9494const handleThrottledBackToTop = useThrottleFn (() => handleBackToTop (), 500 )
9595const handleThrottledPageUnRefresh = useThrottleFn (() => handleUndoRefresh .value ?.(), 500 )
9696const handleThrottledPageForwardRefresh = useThrottleFn (() => handleForwardRefresh .value ?.(), 500 )
@@ -359,6 +359,9 @@ function handleBackToTop(targetScrollTop = 0 as number) {
359359 iframePageRef .value ?.handleBackToTop ()
360360}
361361
362+ // 添加滚动结束检测
363+ let scrollEndTimer: ReturnType <typeof setTimeout > | null = null
364+
362365function handleOsScroll() {
363366 emitter .emit (OVERLAY_SCROLL_BAR_SCROLL )
364367
@@ -373,8 +376,32 @@ function handleOsScroll() {
373376 reachTop .value = false
374377 }
375378
376- if (clientHeight + scrollTop >= scrollHeight - 300 )
379+ // 优化滚动检测:降低阈值,提高敏感度
380+ const threshold = Math .min (200 , clientHeight * 0.2 ) // 动态阈值,最大200px或20%屏幕高度
381+ if (clientHeight + scrollTop >= scrollHeight - threshold ) {
377382 handleThrottledReachBottom ()
383+ }
384+
385+ // 清除之前的滚动结束定时器
386+ if (scrollEndTimer ) {
387+ clearTimeout (scrollEndTimer )
388+ }
389+
390+ // 设置滚动结束检测,在滚动停止150ms后再检查一次
391+ scrollEndTimer = setTimeout (() => {
392+ const osInstance = scrollbarRef .value ?.osInstance ()
393+ if (! osInstance )
394+ return
395+
396+ const { viewport } = osInstance .elements ()
397+ const { scrollTop, scrollHeight, clientHeight } = viewport
398+ const threshold = Math .min (200 , clientHeight * 0.2 )
399+
400+ // 滚动结束后的最终检测,使用更大的阈值确保不遗漏
401+ if (clientHeight + scrollTop >= scrollHeight - threshold * 1.5 ) {
402+ handleReachBottom .value ?.()
403+ }
404+ }, 150 )
378405
379406 if (isHomePage ())
380407 topBarRef .value ?.handleScroll ()
0 commit comments