-
-
Notifications
You must be signed in to change notification settings - Fork 897
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Insert new item and scroll to the end (chat/stream) #110
Comments
This is something I need to improve in the scroller (for some reason the correct In the meanwhile, here is the workaround we use in production at work for our own chat implementation: scrollToBottom (force = true) {
// isScrollBottom is a boolean prop which is true if the user is scrolled at the bottom before the new message is added
if (!this.$_scrollingToBottom && (force || this.isScrollBottom)) {
this.scrollToPosition(999999999)
this.$_scrollingToBottom = true
}
},
scrollToPosition (position) {
const scroller = this.$refs.scroller.$el
scroller.scrollTop = position
requestAnimationFrame(() => {
scroller.scrollTop = position
setTimeout(() => {
scroller.scrollTop = position
this.$_scrollingToBottom = false
}, 50)
})
}, |
Thanks! I'll try it out and will report back! I think the issue is that the RecycleScroller watches the messages prop. So if I update any element in the messages array it will cause the whole list to redraw which also causes the view to jump up. I think the component would need to save the old scroll position before the redraw and automatically readjust the position after the redraw is done. Does your workaround work with dynamic changes in the messages array? The problem I think will occur with your solution is the update of my message status |
No, only the relevant component will be redrawn. |
I think I also found a temporary fix for my scrolling issue while I'm not at the end of the chat. Shouldn't be the norm but just for everyone who looks into this! |
Is there a way to add items to the start of a list? |
@Akryum sadly I'm still struggling with the implementation in our chat application.
Do you have a codesandbox or something which shows how your implementation works? I tried searching for already existing chat examples with this package but really can't find something similar to my needs. |
I solved it by enabling the
Still feels hacky though @Akryum are you working on such kind of a feature? |
Hey @bdbch, @janwiemers I am working one something quite similar and haven't found a reliable way to keep the scroll position when loading in new messages from the top (e.g. when the users scrolls up and triggers fetching new messages). I add them to the back of my message list and tried a few ways calculating the correct offset, but there always seems to be a deviation which makes the scrolling look off and very unpleasant for the user (small jitter or jumping of the list). Did you came up with a solution that works for you? |
@Quasarman any updates about this one? Have you solved your problem? |
I have this problem too, please create this update |
yet another one with the same problem |
So I'm currently working on a chat using this package for a more performant solution on how we render our chat items.
Since chats work a bit different to normal lists I have some issues with the implementation of the automated scrolling when new messages are added. Also updates and resizing just resets the scroll position if changed manually via
el.scrollTop = 1000
for example. Do I need to tell the component that the scroll position was updated and needs to be saved?scrollToItem
isn't working for me, because it always scrolls to the beginning of the item instead of the end. Maybe implementing ascrollToEnd
andscrollToStart
would be good!Here is a codesandbox link:
https://codesandbox.io/s/jn121l1n83
The text was updated successfully, but these errors were encountered: