hooks icon indicating copy to clipboard operation
hooks copied to clipboard

useInfiniteScroll getClientHeight error

Open brickspert opened this issue 3 years ago • 3 comments
trafficstars

想问一下,useInfiniteScroll所使用的getClientHeight这个方法是不是有点问题?这边想获取视窗的高度,应该是使用el.clientHeight || document.documentElement.clientHeight || document.body.clientHeight吧? 经测试,在chrome上document.body.clientHeight会返回body的高度,导致当useInfiniteScroll传入的target为document时,会在未滚动触底的情况下自动触发handler

brickspert avatar Mar 22 '22 10:03 brickspert

如何修复这个问题呢?

taoliujun avatar Apr 20 '22 03:04 taoliujun

如何修复这个问题呢?

参考下这里:https://github.com/alibaba/hooks/pull/1516#issuecomment-1075832893

brickspert avatar Apr 22 '22 04:04 brickspert

如果限定了body的高度,那么失去了以document为滚动父元素的意义,我使用了该方式:https://github.com/alibaba/hooks/issues/1563

taoliujun avatar Apr 22 '22 04:04 taoliujun

统一在 #2119 中处理

hchlq avatar Mar 15 '23 11:03 hchlq