Skip to content

Commit

Permalink
Correct automatic tab scroll positioning in Australis
Browse files Browse the repository at this point in the history
  • Loading branch information
ephemeralViolette committed Feb 24, 2024
1 parent 0e40873 commit 974f116
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
31 changes: 31 additions & 0 deletions Echelon/Profile Folder/chrome/JS/echelon_layout.uc.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ let g_echelonLayoutManager;
toolboxRoot.addEventListener("customizationchange", this);
toolboxRoot.addEventListener("aftercustomization", this);
this.refreshToolboxLayout();
this.hookTabArrowScrollbox();
}

initTabsOnTop()
Expand Down Expand Up @@ -173,6 +174,36 @@ let g_echelonLayoutManager;
}
}
}

/**
* We need this hack for Australis automatic tab scrolling (opening new tab, ctrl+num)
* to work correctly. Otherwise, it will be offset a few pixels into the tab.
*
* This does not negatively affect any other theme, since it just uses a more accurate
* element for positioning instead of the clipped parent element.
*/
async hookTabArrowScrollbox()
{
async function scrollIntoView_hook()
{
return this.querySelector(".tab-background").scrollIntoView();
}

let arrowScrollbox = await waitForElement("#tabbrowser-arrowscrollbox");
let ensureElementIsVisible_orig = arrowScrollbox.ensureElementIsVisible;

/*
* Overriding this method of the arrow scrollbox is basically done
* to avoid having to register something like a mutation observer.
*
* We can just record the arguments of this and install the main
* hook painlessly.
*/
arrowScrollbox.ensureElementIsVisible = function(element, aInstant) {
element.scrollIntoView = scrollIntoView_hook;
ensureElementIsVisible_orig.apply(arrowScrollbox, arguments);
};
}
}

g_echelonLayoutManager = new LayoutManager;
Expand Down
2 changes: 1 addition & 1 deletion Echelon/Profile Folder/chrome/build.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
302
305

0 comments on commit 974f116

Please sign in to comment.