Skip to content

Commit

Permalink
Fix button color desync
Browse files Browse the repository at this point in the history
There must be a better way to do this.
  • Loading branch information
marcustyphoon committed Jul 28, 2023
1 parent be4736f commit 1c28031
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/scripts/scroll_to_bottom.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,18 @@ const addButtonToPage = async function ([scrollToTopButton]) {
document.documentElement.addEventListener('keydown', onKeyDown);
};

const modalButtonColorObserver = new MutationObserver(([mutation]) => {
modalScrollToBottomButton.style = mutation.target.style.cssText;
});

const addModalButtonToPage = async function ([modalScrollToTopButton]) {
modalScrollToBottomButton ??= cloneButton(modalScrollToTopButton);

modalScrollToTopButton.after(modalScrollToBottomButton);
modalScrollToTopButton.addEventListener('click', stopScrolling);
document.documentElement.addEventListener('keydown', onKeyDown);

modalButtonColorObserver.observe(modalScrollToTopButton, { attributeFilter: ['style'] });
};

export const main = async function () {
Expand All @@ -113,6 +119,7 @@ export const main = async function () {

export const clean = async function () {
pageModifications.unregister(addButtonToPage);
modalButtonColorObserver.disconnect();
stopScrolling();
scrollToBottomButton?.remove();
styleElement.remove();
Expand Down

0 comments on commit 1c28031

Please sign in to comment.