fix: ratio bar disappearing on scroll #1253
Open
+1
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
what this fixes
fixes the ratio bar disappearing when you scroll. turns out there was a check that removed the bar element whenever it left the viewport, but it didn't come back unless you clicked something.
related issue
fixes #1252
changes
removed the
isInViewportcheck insrc/bar.jsthat was callingrateBar.remove().the bar now just stays in the dom. when
createRateBargets called (either from navigation or voting), it updates the existing bar instead of trying to recreate it. way simpler.why the old code existed
dug through the git history - the
isInViewportthing was added in commit b5382ba (nov 2022) to deal with "ghost elements" from youtube's spa navigation.makes sense in theory, but it had a flaw: it couldn't tell the difference between a stale element and an element that's just off-screen because you scrolled. so it nuked the bar on every scroll.
testing i did
scroll test
scrolled down until buttons were off screen, scrolled back up. bar stayed visible. ✓
checked for memory leaks
navigated through 10+ videos really fast, then ran this in console:
always returned 1, never created duplicates. ✓
navigation test
clicked between videos, bar updated with new stats immediately. ✓
other stuff
breaking changes?
nope. just removes some unnecessary dom manipulation.
why this is safe
ryd-bar-container), so you can't have duplicatestested locally on firefox & chrome, everything works smoothly.