Skip to content

Commit

Permalink
Fix tab scroll + follow focus (close #62, #74)
Browse files Browse the repository at this point in the history
  • Loading branch information
numirias committed Apr 13, 2021
1 parent 8a331c6 commit 22461e7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/options/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ <h1>Settings</h1>
<div><label for="maxTabRows">Max. number of tab rows <small>(before scrollbar appears)</small></label></div>
<div><input id="maxTabRows" type="number"></div>

<div><label for="fitLightness">Fit lightness to themes</label></div>
<div><label for="fitLightness">Fit tab lightness to current theme</label></div>
<div><input id="fitLightness" type="checkbox"></div>

<div><label for="minLightness">Min. tab color lightness <small>(best on dark theme: 59, light theme: 0)</small></label></div>
Expand Down
21 changes: 21 additions & 0 deletions src/paxmod-api-experiment/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,21 @@ function patch(win) {
tab.style.transform = ''
}
})
patchMethod('_handleTabSelect', function(aInstant) {
// Only when "overflow" attribute is set, the selected tab will get
// automatically scrolled into view
this.setAttribute('overflow', 'true')
this._handleTabSelect_orig(aInstant)
})
win.document.querySelector('#tabbrowser-tabs')._positionPinnedTabs()
// Make sure the arrowscrollbox doesn't swallow mouse wheel events, so they
// get propagated to the tab list, allowing the user to scroll up and down
let arrowscrollbox = win.document.querySelector('#tabbrowser-arrowscrollbox')
if (arrowscrollbox) {
arrowscrollbox.removeEventListener('wheel', arrowscrollbox.on_wheel)
} else {
console.warn('Paxmod: arrowscrollbox not found')
}
}

function unpatch(win) {
Expand All @@ -105,6 +119,13 @@ function unpatch(win) {
unpatchMethod('_positionPinnedTabs')
unpatchMethod('on_drop')
unpatchMethod('on_dragover')
unpatchMethod('_handleTabSelect')
let arrowscrollbox = win.document.querySelector('#tabbrowser-arrowscrollbox')
if (arrowscrollbox) {
arrowscrollbox.addEventListener('wheel', arrowscrollbox.on_wheel)
} else {
console.warn('Paxmod: arrowscrollbox not found')
}
}

this.paxmod = class extends ExtensionAPI {
Expand Down

0 comments on commit 22461e7

Please sign in to comment.