AprilSylph / XKit-Rewritten

🧰 The enhancement suite for Tumblr's new web interface
GNU General Public License v3.0
274 stars 44 forks source link

Scroll to Bottom breaks on some timelines; blog lists; activity #1491

Open marcustyphoon opened 2 weeks ago

marcustyphoon commented 2 weeks ago

Platform

MacOS 14.4.1 arm64

Browser

Chrome 125.0.6422.77

Addon version

dev branch

Details

https://github.com/AprilSylph/XKit-Rewritten/blob/a92be15496450118418166676fb3c978868cb20f/src/scripts/scroll_to_bottom.js#L10-L13

Scroll to Bottom stops after the first jump on all V2 timelines. I believe it is due to the :last-child here not matching the div containing the loader element any more, as the last child of the V2 timeline is an empty div (a react-intersection-observer inView, if the google results for _unobserveCb are to be believed).

marcustyphoon commented 2 weeks ago

Nope, it's not just that. The loader is not shown all the time and removed when there is nothing else to load any more; rather, it is only added when the endless scrolling element is actively loading, and this state does not appear to be applied synchronously. We're probably going to have to wait an arbitrary time for it to appear, I guess.

marcustyphoon commented 2 weeks ago

After a bit of poking, it doesn't seem like it's a good idea to try to use some understanding of the timing and order of when certain things happen in the scroll process to precisely target when the loader should be checked for. I could probably figure out what's occurring on each frame of this process, but something like "wait n requestAnimationFrames" isn't that robust, and more importantly, it seems like our resize observer can be triggered multiple times during this process due to the whole mess about how cell repositioning and resizing works on a delay, so it would be meaningless anyway.

(image is for flavor)

Thinking about a technique that doesn't really care about event order at all... maybe one could, like:

So the scroll gets cancelled if we scroll, and in the next n milliseconds, no scroll occurs, no loader gets added and no loader exists. The scroll doesn't get cancelled if there is still a loader (timeline v1) or if a loader gets added or removed, or if a — yeah.

Pretty sure there are no race conditions in that.