mirror of
https://github.com/zen-browser/desktop.git
synced 2025-07-10 02:06:24 +02:00
Refactor sidebar scrolling initialization and enhance tab visibility checks
This commit is contained in:
parent
7077a01dad
commit
3931f8195b
3 changed files with 62 additions and 8 deletions
|
@ -31,13 +31,7 @@
|
|||
document.getElementById('zen-appcontent-navbar-container').appendChild(deckTemplate);
|
||||
}
|
||||
|
||||
// Disable smooth scroll
|
||||
if (!Services.prefs.getBoolPref('zen.startup.smooth-scroll-in-tabs', false)) {
|
||||
gBrowser.tabContainer.addEventListener('wheel', (event) => {
|
||||
event.preventDefault(); // Prevent the smooth scroll behavior
|
||||
gBrowser.tabContainer.scrollTop += event.deltaY * 20; // Apply immediate scroll
|
||||
});
|
||||
}
|
||||
this._initSidebarScrolling();
|
||||
|
||||
gZenCompactModeManager.init();
|
||||
ZenWorkspaces.init();
|
||||
|
@ -88,6 +82,35 @@
|
|||
}
|
||||
},
|
||||
|
||||
_initSidebarScrolling() {
|
||||
// Disable smooth scroll
|
||||
if (!Services.prefs.getBoolPref('zen.startup.smooth-scroll-in-tabs', false)) {
|
||||
gBrowser.tabContainer.addEventListener('wheel', (event) => {
|
||||
event.preventDefault(); // Prevent the smooth scroll behavior
|
||||
gBrowser.tabContainer.scrollTop += event.deltaY * 20; // Apply immediate scroll
|
||||
});
|
||||
}
|
||||
// Detect overflow and underflow
|
||||
const observer = new ResizeObserver((_) => {
|
||||
const tabContainer = gBrowser.tabContainer;
|
||||
const isVertical = tabContainer.getAttribute('orient') === 'vertical';
|
||||
let contentSize =
|
||||
tabContainer.getBoundingClientRect()[isVertical ? 'height' : 'width'];
|
||||
// NOTE: This should be contentSize > scrollClientSize, but due
|
||||
// to how Gecko internally rounds in those cases, we allow for some
|
||||
// minor differences (the internal Gecko layout size is 1/60th of a
|
||||
// pixel, so 0.02 should cover it).
|
||||
let overflowing = contentSize - tabContainer.arrowScrollbox.scrollClientSize > 0.02;
|
||||
|
||||
tabContainer.arrowScrollbox.toggleAttribute("overflowing", overflowing);
|
||||
tabContainer.arrowScrollbox.dispatchEvent(
|
||||
new CustomEvent(overflowing ? "overflow" : "underflow")
|
||||
);
|
||||
});
|
||||
observer.observe(document.getElementById('navigator-toolbox'));
|
||||
|
||||
},
|
||||
|
||||
_initSearchBar() {
|
||||
// Only focus the url bar
|
||||
gURLBar.focus();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue