From 2d97b3b181389ff17fe6ff97789c13fe394c784a Mon Sep 17 00:00:00 2001 From: CosmoCreeper <179134799+CosmoCreeper@users.noreply.github.com> Date: Sat, 7 Jun 2025 10:11:47 -0400 Subject: [PATCH 01/10] Consolidate scrolling ability into a singular function, add scroll listener to workspace indicator and icons container. Signed-off-by: CosmoCreeper <179134799+CosmoCreeper@users.noreply.github.com> --- src/zen/workspaces/ZenWorkspaces.mjs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/zen/workspaces/ZenWorkspaces.mjs b/src/zen/workspaces/ZenWorkspaces.mjs index 31e0aae529..26817214e0 100644 --- a/src/zen/workspaces/ZenWorkspaces.mjs +++ b/src/zen/workspaces/ZenWorkspaces.mjs @@ -465,6 +465,7 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature { tabs ); this.initIndicatorContextMenu(workspaceWrapper.indicator); + this.initScrollEvent(workspaceWrapper.indicator); resolve(); }, { once: true } @@ -544,6 +545,14 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature { } } + scrollInDirection(delta) { + // Determine scroll direction + let rawDirection = delta > 0 ? 1 : -1; + + let direction = this.naturalScroll ? -1 : 1; + this.changeWorkspaceShortcut(rawDirection * direction); + } + _setupSidebarHandlers() { const toolbox = gNavToolbox; @@ -585,11 +594,7 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature { const delta = isVerticalScroll ? event.deltaY : event.deltaX; if (Math.abs(delta) < scrollThreshold) return; - // Determine scroll direction - let rawDirection = delta > 0 ? 1 : -1; - - let direction = this.naturalScroll ? -1 : 1; - this.changeWorkspaceShortcut(rawDirection * direction); + this.scrollInDirection(delta); this._lastScrollTime = currentTime; }, @@ -994,6 +999,10 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature { indicator.addEventListener('click', th); } + initScrollEvent(element) { + element.addEventListener('wheel', (event) => this.scrollInDirection(event.deltaY)); + } + shouldCloseWindow() { return ( !window.toolbar.visible || Services.prefs.getBoolPref('browser.tabs.closeWindowWithLastTab') @@ -2522,6 +2531,7 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature { gZenUIManager.tabsWrapper.scrollbarWidth = 'none'; this.workspaceIcons.activeIndex = workspace.uuid; + this.initScrollEvent(this.workspaceIcons); await this._animateTabs(workspace, !onInit && !this._animatingChange, tabToSelect, { previousWorkspaceIndex, previousWorkspace, From 1c151d58d10a13b124f8eaa0af343ff0d5e97e3b Mon Sep 17 00:00:00 2001 From: CosmoCreeper <179134799+CosmoCreeper@users.noreply.github.com> Date: Sat, 7 Jun 2025 10:30:40 -0400 Subject: [PATCH 02/10] Remove the zen workspace icons container event. Signed-off-by: CosmoCreeper <179134799+CosmoCreeper@users.noreply.github.com> --- src/zen/workspaces/ZenWorkspaces.mjs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/zen/workspaces/ZenWorkspaces.mjs b/src/zen/workspaces/ZenWorkspaces.mjs index 26817214e0..477f97a8f4 100644 --- a/src/zen/workspaces/ZenWorkspaces.mjs +++ b/src/zen/workspaces/ZenWorkspaces.mjs @@ -2531,7 +2531,6 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature { gZenUIManager.tabsWrapper.scrollbarWidth = 'none'; this.workspaceIcons.activeIndex = workspace.uuid; - this.initScrollEvent(this.workspaceIcons); await this._animateTabs(workspace, !onInit && !this._animatingChange, tabToSelect, { previousWorkspaceIndex, previousWorkspace, From 6f2799299c92beb1d70af9b18e6a9c95d9f3b6a8 Mon Sep 17 00:00:00 2001 From: CosmoCreeper <179134799+CosmoCreeper@users.noreply.github.com> Date: Sat, 7 Jun 2025 10:31:24 -0400 Subject: [PATCH 03/10] Add the event to the individual buttons. Signed-off-by: CosmoCreeper <179134799+CosmoCreeper@users.noreply.github.com> --- src/zen/workspaces/ZenWorkspaceIcons.mjs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/zen/workspaces/ZenWorkspaceIcons.mjs b/src/zen/workspaces/ZenWorkspaceIcons.mjs index c093f16e97..df85a35595 100644 --- a/src/zen/workspaces/ZenWorkspaceIcons.mjs +++ b/src/zen/workspaces/ZenWorkspaceIcons.mjs @@ -30,6 +30,7 @@ } button.appendChild(icon); button.addEventListener('command', this); + gZenWorkspaces.initScrollEvent(button); return button; } From e87f2ef1f6cffaa03cfaf49113e820eb1012daee Mon Sep 17 00:00:00 2001 From: CosmoCreeper <179134799+CosmoCreeper@users.noreply.github.com> Date: Sat, 7 Jun 2025 13:18:49 -0400 Subject: [PATCH 04/10] Remove icon scrolling completely. Signed-off-by: CosmoCreeper <179134799+CosmoCreeper@users.noreply.github.com> --- src/zen/workspaces/ZenWorkspaceIcons.mjs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/zen/workspaces/ZenWorkspaceIcons.mjs b/src/zen/workspaces/ZenWorkspaceIcons.mjs index df85a35595..c093f16e97 100644 --- a/src/zen/workspaces/ZenWorkspaceIcons.mjs +++ b/src/zen/workspaces/ZenWorkspaceIcons.mjs @@ -30,7 +30,6 @@ } button.appendChild(icon); button.addEventListener('command', this); - gZenWorkspaces.initScrollEvent(button); return button; } From 7a01ead6ae211d4de6cd3922aba5a553b93b27e1 Mon Sep 17 00:00:00 2001 From: CosmoCreeper <179134799+CosmoCreeper@users.noreply.github.com> Date: Sat, 7 Jun 2025 13:19:26 -0400 Subject: [PATCH 05/10] Update ZenWorkspaces.mjs Signed-off-by: CosmoCreeper <179134799+CosmoCreeper@users.noreply.github.com> --- src/zen/workspaces/ZenWorkspaces.mjs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/zen/workspaces/ZenWorkspaces.mjs b/src/zen/workspaces/ZenWorkspaces.mjs index d9cdcc6d5f..6519b9c2c8 100644 --- a/src/zen/workspaces/ZenWorkspaces.mjs +++ b/src/zen/workspaces/ZenWorkspaces.mjs @@ -465,7 +465,7 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature { tabs ); this.initIndicatorContextMenu(workspaceWrapper.indicator); - this.initScrollEvent(workspaceWrapper.indicator); + workspaceWrapper.indicator.addEventListener('wheel', (event) => this.scrollInDirection(event.deltaY)); resolve(); }, { once: true } @@ -1000,10 +1000,6 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature { indicator.addEventListener('click', th); } - initScrollEvent(element) { - element.addEventListener('wheel', (event) => this.scrollInDirection(event.deltaY)); - } - shouldCloseWindow() { return ( !window.toolbar.visible || Services.prefs.getBoolPref('browser.tabs.closeWindowWithLastTab') From 0c4226ceb6d2d395e5ea20f84ffb27804e266bbe Mon Sep 17 00:00:00 2001 From: CosmoCreeper <179134799+CosmoCreeper@users.noreply.github.com> Date: Mon, 9 Jun 2025 19:53:45 -0400 Subject: [PATCH 06/10] Add touchpad accidental scrolling prevention. Signed-off-by: CosmoCreeper <179134799+CosmoCreeper@users.noreply.github.com> --- src/zen/workspaces/ZenWorkspaces.mjs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/zen/workspaces/ZenWorkspaces.mjs b/src/zen/workspaces/ZenWorkspaces.mjs index 6519b9c2c8..0e64427c21 100644 --- a/src/zen/workspaces/ZenWorkspaces.mjs +++ b/src/zen/workspaces/ZenWorkspaces.mjs @@ -465,7 +465,17 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature { tabs ); this.initIndicatorContextMenu(workspaceWrapper.indicator); - workspaceWrapper.indicator.addEventListener('wheel', (event) => this.scrollInDirection(event.deltaY)); + workspaceWrapper.indicator.addEventListener('wheel', (event) => { + let isTrackpad = false; + if ((event.wheelDeltaY && event.wheelDeltaY === (event.deltaY * -3)) || event.deltaMode === 0) { + isTrackpad = true; + } + + const verticalScroll = Math.abs(event.deltaY) > Math.abs(event.deltaX); + if ((isTrackpad && verticalScroll) || !isTrackpad) { + this.scrollInDirection(event.deltaY); + } + }); resolve(); }, { once: true } From 727d6a70879443776e3f6cd2ee7b003e7fa597b4 Mon Sep 17 00:00:00 2001 From: CosmoCreeper <179134799+CosmoCreeper@users.noreply.github.com> Date: Tue, 10 Jun 2025 09:18:28 -0400 Subject: [PATCH 07/10] Make unchanged variables constant. Signed-off-by: CosmoCreeper <179134799+CosmoCreeper@users.noreply.github.com> --- src/zen/workspaces/ZenWorkspaces.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/zen/workspaces/ZenWorkspaces.mjs b/src/zen/workspaces/ZenWorkspaces.mjs index 09254e856f..2c1a91dad0 100644 --- a/src/zen/workspaces/ZenWorkspaces.mjs +++ b/src/zen/workspaces/ZenWorkspaces.mjs @@ -563,9 +563,9 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature { scrollInDirection(delta) { // Determine scroll direction - let rawDirection = delta > 0 ? 1 : -1; + const rawDirection = delta > 0 ? 1 : -1; - let direction = this.naturalScroll ? -1 : 1; + const direction = this.naturalScroll ? -1 : 1; this.changeWorkspaceShortcut(rawDirection * direction); } From e72cf38b8337d7ac0b89fed8a267cab21fd4ce7d Mon Sep 17 00:00:00 2001 From: CosmoCreeper <179134799+CosmoCreeper@users.noreply.github.com> Date: Tue, 10 Jun 2025 09:35:12 -0400 Subject: [PATCH 08/10] Formatted workspace file to obey linter format. Signed-off-by: CosmoCreeper <179134799+CosmoCreeper@users.noreply.github.com> --- src/zen/workspaces/ZenWorkspaces.mjs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/zen/workspaces/ZenWorkspaces.mjs b/src/zen/workspaces/ZenWorkspaces.mjs index 2c1a91dad0..9b7a189530 100644 --- a/src/zen/workspaces/ZenWorkspaces.mjs +++ b/src/zen/workspaces/ZenWorkspaces.mjs @@ -470,7 +470,10 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature { this.initIndicatorContextMenu(workspaceWrapper.indicator); workspaceWrapper.indicator.addEventListener('wheel', (event) => { let isTrackpad = false; - if ((event.wheelDeltaY && event.wheelDeltaY === (event.deltaY * -3)) || event.deltaMode === 0) { + if ( + (event.wheelDeltaY && event.wheelDeltaY === event.deltaY * -3) || + event.deltaMode === 0 + ) { isTrackpad = true; } From f0c169626ccd1689947e77a8e4c574a11180779b Mon Sep 17 00:00:00 2001 From: CosmoCreeper <179134799+CosmoCreeper@users.noreply.github.com> Date: Wed, 11 Jun 2025 09:13:05 -0400 Subject: [PATCH 09/10] Update to singular variable. Co-authored-by: Burhanuddin Salim Signed-off-by: CosmoCreeper <179134799+CosmoCreeper@users.noreply.github.com> --- src/zen/workspaces/ZenWorkspaces.mjs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/zen/workspaces/ZenWorkspaces.mjs b/src/zen/workspaces/ZenWorkspaces.mjs index 9b7a189530..9786a1ef10 100644 --- a/src/zen/workspaces/ZenWorkspaces.mjs +++ b/src/zen/workspaces/ZenWorkspaces.mjs @@ -469,13 +469,9 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature { ); this.initIndicatorContextMenu(workspaceWrapper.indicator); workspaceWrapper.indicator.addEventListener('wheel', (event) => { - let isTrackpad = false; - if ( + const isTrackpad = (event.wheelDeltaY && event.wheelDeltaY === event.deltaY * -3) || - event.deltaMode === 0 - ) { - isTrackpad = true; - } + event.deltaMode === 0; const verticalScroll = Math.abs(event.deltaY) > Math.abs(event.deltaX); if ((isTrackpad && verticalScroll) || !isTrackpad) { From 8c0614f41d10b3965647544655eecd1c51f8ad7a Mon Sep 17 00:00:00 2001 From: CosmoCreeper <179134799+CosmoCreeper@users.noreply.github.com> Date: Wed, 11 Jun 2025 13:56:40 -0400 Subject: [PATCH 10/10] Update src/zen/workspaces/ZenWorkspaces.mjs Co-authored-by: Burhanuddin Salim Signed-off-by: CosmoCreeper <179134799+CosmoCreeper@users.noreply.github.com> --- src/zen/workspaces/ZenWorkspaces.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/zen/workspaces/ZenWorkspaces.mjs b/src/zen/workspaces/ZenWorkspaces.mjs index 9786a1ef10..2b81fd7f5f 100644 --- a/src/zen/workspaces/ZenWorkspaces.mjs +++ b/src/zen/workspaces/ZenWorkspaces.mjs @@ -474,7 +474,7 @@ var gZenWorkspaces = new (class extends ZenMultiWindowFeature { event.deltaMode === 0; const verticalScroll = Math.abs(event.deltaY) > Math.abs(event.deltaX); - if ((isTrackpad && verticalScroll) || !isTrackpad) { + if (!isTrackpad || verticalScroll) { this.scrollInDirection(event.deltaY); } });