this post was submitted on 25 Mar 2025
6 points (100.0% liked)

Photon

453 readers
39 users here now

Photon for Lemmy

A client for the fediverse designed to be intuitive, fast, and beautiful.

Share your themes, ask questions, report bugs, or check on the latest updates here!

You can contact the dev at @Xylight@lemdro.id.

Rules

  1. Posts must be related to Photon in any way
  2. Don't be mean
  3. If your post is a bug report, please preface the title with [solved] if it's been fixed.

founded 1 year ago
MODERATORS
 

Upon going back to the feed page from a post page, the feed tends to load in at a different point (higher up) than where it was before. This results in a lot of repetitive scrolling.

Also, I noticed that (when new content is being loaded in?) the scrolling gets stuck in the same spot. Scrolling kind of just glitches on the same spot until it gets past it and then resumes as normal.

top 5 comments
sorted by: hot top controversial new old
[–] moseschrute@lemmy.world 4 points 1 week ago

I don’t use Photon, but I glanced at the source code and it looks like they are also using Tanstack Virtual, which my Lemmy client uses. My app is in beta an doesn’t have many users, but I think I solved this feed issue.

You need to do a few things:

  1. On scroll, save the first item being rendered in the virtual list + the offset of that item from the top (offset can be negative or positive)
  2. Pause the virtualization when the list is no longer visible (use IntersectionObserver)
  3. When the user returns to the list, reenable virtualization while simultaneously recalculating initalOffset to be passed to the virtual list.

You have to recalculate initalOffset when returning to the list, NOT when you are scrolling through the list. If you try to calculate it while scrolling the feed, you will drift a few posts upwards/downwards. Using initial item + offset yields a much more stable result.

It’s all pretty messy, but take a look at my spaghetti code.

[–] Xylight@lemdro.id 1 points 1 week ago (1 children)

I'm definitely gonna have to write my own virtualizer. I tried using Tanstack Virtual but it definitely has too many issues with my setup to work well.

[–] technomad@slrpnk.net 1 points 1 week ago (1 children)

Did you see moseschrute's reply? Just curious

[–] Xylight@lemdro.id 1 points 1 week ago* (last edited 1 week ago) (1 children)

I did. In the long run it's better for me to write my own since it's easier to update and debug

[–] technomad@slrpnk.net 1 points 3 days ago

I just wanted to say thanks for the reply btw. I look forward to seeing the updates whenever they may come, and I appreciate what you do!