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
Keep focus on previous item when prepending items to the list #68
Comments
Hi Alex. I'm not too sure what you mean by this. Could you create a quick fiddle to reproduce this and we'll go from there? You may use this demo fiddle as a baseline. Thanks 😃 |
@theomessin Hi Theodore, of course, here is the fiddle: https://jsfiddle.net/584ufysj/2/ Instead, they should be chronologically scrollable, which means when the messages are added the client should see first the message "New Message 0: lorem ipsum" and scrolls up to see the rest of it. |
I see now. Yeah that makes sense. We'll have to think how we can go about implementing this. |
I have already tried it a bit, but havn't yet come to any promising solution. |
This comment has been minimized.
This comment has been minimized.
I've come up with a solution I'll be implementing in the alpha channel. Stay tuned 😉 Will basically have a sticky option that keeps the scroll window constant even if items are prepended. All you have to do is activate this flag if the scroll position is |
@alex-w0 @weeliem So here's what I've got working from the alpha: https://jsfiddle.net/theomessin/zhjdm0qb/ If you scroll to the top, it'll load new messages but the view should remain where it was. In practise this will be achieved by enabling the |
yea @theomessin nicely done, this is what i want. Hope to have this feature enabled in the next version :) Thanks. |
@theomessin Great job, works really well, thanks :) Do you have committed somewhere this feature? I'm just curious how you did it. |
I'll get a PR with this for v2.0.0-alpha tonight. It's not the most high-performance implementation but it works nicely I think. For each Mutation (eventually this will probably be a ResizeMutation see #72) we keep the scrollHeight in a WeakMap. When prepending, we scroll so that scrollTop is the difference in heights (ie. we scroll back where we were). I'll probably add a flag to disable saving the height as it does incur a performance penalty that some users might want to avoid. |
@alex-w0 @weeliem wouldn't mind some feedback on this implementation. Here's the same fiddle using the If happy with this, we can go ahead and close this issue. |
@theomessin yea, tested and working fine :) Thanks a lot for the add-on. |
Feel free to re-open this issue if there are any problems. |
Is your feature request related to a problem? Please describe.
Last week I've created the pull request for the event @v-chat-scroll-top-reached, which works fine.
When I'm prepending new items to the list, then the position of the scrollbar still remains on top.
Instead the focus should be kept on the previous item that was on top.
Do you have suggestions how we can solve this problem?
The text was updated successfully, but these errors were encountered: