damus-io / notedeck

A multiplatform nostr client
Other
52 stars 9 forks source link

Put together failing test case for egui_virtual_list #38

Closed jb55 closed 1 month ago

jb55 commented 2 months ago

@lucasmerlin's egui_virtual_list seems to not support adding items to the start of a list in reverse chrononological order. when you scroll up it tends to skip:

https://cdn.jb55.com/s/virtual-list-buggy.mp4

Let's put together a minimal failing test case so that we can investigate this issue.

Alternatively we can look into @mikedilger's approach in gossip.

lucasmerlin commented 2 months ago

This is actually a problem I also had with egui_infinite_scroll (which also supports loading items from the top when scrolling up), and there is a fix for it (although not very pretty): You can call items_inserted_at_start when you add items at the top, and it will measure the height of the inserted items and scroll by the measured amount to prevent it from jumping around. (This was actually a pain to implement because it's not something egui's ScrollArea supports on it's own, and scrolling a certain amount was buggy at that time)

~You can also look at the both_directions example in the infinite scroll crate to see it implemented.~ (Sorry I was confusing infinite_scroll and virtual_list, but you could look at the infinite scroll source code to see how it interacts with egui_virtual_list to add items at the top)

jb55 commented 1 month ago

@lucasmerlin oops I just saw this comment. thanks! I will check out that code. it sounds like that's what we need.

jb55 commented 1 month ago

@lucasmerlin I added the call right after I insert data into the list before render, I get this (starts at 5seconds):

https://cdn.jb55.com/s/bumpy.mp4

jb55 commented 1 month ago

oh I may just need to turn off scroll animations... that makes sense

lucasmerlin commented 1 month ago

Yeah, the scroll animations are the problem. Are you using the latest egui version? You should be able to do ScrollArea::animated to turn them off. Related egui stuff: https://github.com/emilk/egui/pull/4309 https://github.com/emilk/egui/issues/4295

jb55 commented 1 month ago

turning off animations fixed everything! this works great now. amazing. thanks!!