Skip to content

Commit

Permalink
Keep tabs scroll-locked even if the cursor is moved while the last ta…
Browse files Browse the repository at this point in the history
…b is being removed #3318
  • Loading branch information
piroor committed Apr 7, 2023
1 parent 8cc8bc5 commit 71f9937
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion webextensions/background/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* The Original Code is the Tree Style Tab.
*
* The Initial Developer of the Original Code is YUKI "Piro" Hiroshi.
* Portions created by the Initial Developer are Copyright (C) 2011-2021
* Portions created by the Initial Developer are Copyright (C) 2011-2023
* the Initial Developer. All Rights Reserved.
*
* Contributor(s): YUKI "Piro" Hiroshi <[email protected]>
Expand Down
22 changes: 17 additions & 5 deletions webextensions/sidebar/scroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -760,11 +760,23 @@ function tryUnlockPosition(event) {
log(' => ignore events while the context menu is opened');
return;
}
if (event.type == 'mousemove' &&
(EventUtils.getTabFromEvent(event, { force: true }) ||
EventUtils.getTabFromTabbarEvent(event, { force: true }))) {
log(' => ignore mousemove on any tab');
return;
if (event.type == 'mousemove') {
if (EventUtils.getTabFromEvent(event, { force: true }) ||
EventUtils.getTabFromTabbarEvent(event, { force: true })) {
log(' => ignore mousemove on any tab');
return;
}
// When you move mouse while the last tab is being removed, it can fire
// a mousemove event on the background area of the tab bar, and it
// produces sudden scrolling. So we need to keep scroll locked
// while the cursor is still on tabs area.
const spacer = mTabBar.querySelector(`.${Constants.kTABBAR_SPACER}`);
const pinnedTabsAreaSize = parseFloat(document.documentElement.style.getPropertyValue('--pinned-tabs-area-size'));
if ((!spacer || event.clientY < spacer.getBoundingClientRect().top) &&
(pinnedTabsAreaSize && !isNaN(pinnedTabsAreaSize) && event.clientY > pinnedTabsAreaSize)) {
log(' => ignore mousemove on any tab (removing)');
return;
}
}

default:
Expand Down

0 comments on commit 71f9937

Please sign in to comment.