Skip to content

Commit

Permalink
hide the autoscroll resume button when it shouldn't be visible
Browse files Browse the repository at this point in the history
hide the element when the user switches to another tab & hide it when we run the cleanup function.
  • Loading branch information
varun7654 committed Jan 5, 2025
1 parent da28e18 commit 6bdb2b1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/modules/ui/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ BetterLyrics.DOM = {
if (existingFooter && existingFooter.classList.contains("blyrics--fallback")) {
existingFooter.classList.remove("blyrics--fallback");
}
BetterLyrics.DOM.getResumeScrollElement().setAttribute("autoscroll-hidden", "true");

BetterLyrics.DOM.clearLyrics();
},
Expand Down Expand Up @@ -461,6 +462,7 @@ BetterLyrics.DOM = {
elem.setAttribute("autoscroll-hidden", "true");
elem.addEventListener("click", () => {
BetterLyrics.DOM.scrollResumeTime = 0;
elem.setAttribute("autoscroll-hidden", "true");
});

document.querySelector("#side-panel > tp-yt-paper-tabs").after(wrapper);
Expand Down
5 changes: 5 additions & 0 deletions src/modules/ui/observer.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,18 @@ BetterLyrics.Observer = {

if (tab1 !== undefined && tab2 !== undefined && tab3 !== undefined) {
tab2.addEventListener("click", function () {
BetterLyrics.DOM.getResumeScrollElement().classList.remove("blyrics-hidden");
if (!BetterLyrics.App.areLyricsLoaded) {
BetterLyrics.Utils.log(BetterLyrics.Constants.LYRICS_TAB_CLICKED_LOG);
BetterLyrics.DOM.cleanup();
BetterLyrics.DOM.renderLoader();
BetterLyrics.App.reloadLyrics();
}
});

let hideAutoscrollResume = () => BetterLyrics.DOM.getResumeScrollElement().classList.add("blyrics-hidden");
tab1.addEventListener("click", hideAutoscrollResume);
tab3.addEventListener("click", hideAutoscrollResume);
} else {
setTimeout(() => BetterLyrics.Observer.lyricReloader(), 1000);
}
Expand Down

0 comments on commit 6bdb2b1

Please sign in to comment.