vue3-virtual-scroll-list
vue3-virtual-scroll-list copied to clipboard
请问chat聊天,如果新消息来时
请问chat聊天,如果新消息来时,当前滚动条在底部,他可以正常一直滚动到底部,但是有一种场景就是滚动条在中间或者在其他位置时(不在最下方),此时新消息来了,不让它滚动到最底部,我应该如何去做呢,我如何知道当前滚动条是否在最下方,或者说距离下方的有个阈值,只要是在触发了阈值就回馈到底部的方法。 我目前的办法是:使用了@scroll="scroll" @tobottom="onBottom" 这两个方法来进行工作,但是触底时onBottom比scroll先到来。 期待你的回复
在receivedRandomMessage
函数里面,注释掉setVirtualListToBottom
就不会滚动到最底部了。
但是还有一种情况,就是接收到消息时,如果在底部,那么就需要保持滚动到底部的情况,你说的这种是每次都不会滚动到底部。
但是如果在底部,那么是需要保持滚动到底部的。我如何知道是否在底部,我目前是使用的伪代码
throttle
是一个节流函数
我还有其他办法实现这种功能吗
发布了v0.2.1,可以用实例的getScrollSize
、getOffset
、getClientSize
计算是否在底部。
好的,感谢你的付出! 但是npm仓库没有看见新版本0.2.1
好的,感谢你的付出! 但是npm仓库没有看见新版本0.2.1
直接修改版本号安装就可以,npm官网页面没有实时更新。
但是真的沒有,淘宝npm镜像中也没有v0.2.1
D:\vuecode\leaguetool>yarn add [email protected]
yarn add v1.22.18
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix
package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning,
remove package-lock.json.
[1/4] Resolving packages...
Couldn't find any versions for "vue3-virtual-scroll-list" that matches "0.2.1"
? Please choose a version of "vue3-virtual-scroll-list" from this list: (Use arrow keys)
> 0.2.0
0.1.2
0.1.1
0.1.0
但是真的沒有,淘宝npm镜像中也没有v0.2.1
![]()
D:\vuecode\leaguetool>yarn add [email protected]
yarn add v1.22.18
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix
package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning,
remove package-lock.json.
[1/4] Resolving packages...
Couldn't find any versions for "vue3-virtual-scroll-list" that matches "0.2.1"
? Please choose a version of "vue3-virtual-scroll-list" from this list: (Use arrow keys)
> 0.2.0
0.1.2
0.1.1
0.1.0
再刷新下,取临界值为10的话,这样判断一下是否在底部就可以了