Refactor workspace icon handling and improve animation state management

This commit is contained in:
mr. M
2025-01-06 00:46:17 +01:00
parent bb96eb1a8d
commit b9f0d39d1c
4 changed files with 13 additions and 13 deletions

File diff suppressed because one or more lines are too long

View File

@@ -65,7 +65,7 @@ var gZenCompactModeManager = {
}, },
flashSidebarIfNecessary(aInstant = false) { flashSidebarIfNecessary(aInstant = false) {
if (!aInstant && this.prefefence && lazyCompactMode.COMPACT_MODE_FLASH_ENABLED && !gZenGlanceManager.animatingOpen) { if (!aInstant && this.prefefence && lazyCompactMode.COMPACT_MODE_FLASH_ENABLED && !gZenGlanceManager._animating) {
this.flashSidebar(); this.flashSidebar();
} }
}, },

View File

@@ -3,7 +3,7 @@
#currentBrowser = null; #currentBrowser = null;
#currentTab = null; #currentTab = null;
#animating = false; _animating = false;
init() { init() {
document.documentElement.setAttribute('zen-glance-uuid', gZenUIManager.generateUuidv4()); document.documentElement.setAttribute('zen-glance-uuid', gZenUIManager.generateUuidv4());
@@ -86,6 +86,8 @@
const currentTab = gBrowser.selectedTab; const currentTab = gBrowser.selectedTab;
this.animatingOpen = true; this.animatingOpen = true;
this._animating = true;
const browserElement = this.createBrowserElement(url, currentTab); const browserElement = this.createBrowserElement(url, currentTab);
this.overlay = browserElement.closest('.browserSidebarContainer'); this.overlay = browserElement.closest('.browserSidebarContainer');
@@ -107,18 +109,17 @@
this.overlay.removeAttribute('fade-out'); this.overlay.removeAttribute('fade-out');
this.browserWrapper.setAttribute('animate', true); this.browserWrapper.setAttribute('animate', true);
this.#animating = true;
setTimeout(() => { setTimeout(() => {
this.browserWrapper.setAttribute('animate-end', true); this.browserWrapper.setAttribute('animate-end', true);
this.browserWrapper.setAttribute('has-finished-animation', true); this.browserWrapper.setAttribute('has-finished-animation', true);
this.#animating = false; this._animating = false;
this.animatingOpen = false; this.animatingOpen = false;
}, 500); }, 500);
}); });
} }
closeGlance({ noAnimation = false, onTabClose = false } = {}) { closeGlance({ noAnimation = false, onTabClose = false } = {}) {
if (this.#animating || !this.#currentBrowser || this.animatingOpen || this._duringOpening) { if (this._animating || !this.#currentBrowser || this.animatingOpen || this._duringOpening) {
return; return;
} }
@@ -130,6 +131,8 @@
return; return;
} }
this._animating = true;
gBrowser._insertTabAtIndex(this.#currentTab, { gBrowser._insertTabAtIndex(this.#currentTab, {
index: this.currentParentTab._tPos + 1, index: this.currentParentTab._tPos + 1,
}); });
@@ -195,6 +198,8 @@
this.lastCurrentTab = null; this.lastCurrentTab = null;
this._duringOpening = false; this._duringOpening = false;
this._animating = false;
}, 400); }, 400);
}); });
}); });

View File

@@ -463,10 +463,6 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
return tab; return tab;
} }
_kIcons = JSON.parse(Services.prefs.getStringPref('zen.workspaces.icons')).map((icon) =>
typeof Intl.Segmenter !== 'undefined' ? new Intl.Segmenter().segment(icon).containing().segment : Array.from(icon)[0]
);
searchIcons(input, icons) { searchIcons(input, icons) {
input = input.toLowerCase(); input = input.toLowerCase();
@@ -543,7 +539,8 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
let container = document.getElementById('PanelUI-zen-workspaces-icon-picker-wrapper'); let container = document.getElementById('PanelUI-zen-workspaces-icon-picker-wrapper');
let searchInput = document.getElementById('PanelUI-zen-workspaces-icon-search-input'); let searchInput = document.getElementById('PanelUI-zen-workspaces-icon-search-input');
searchInput.value = ''; searchInput.value = '';
for (let icon of this._kIcons) { for (let iconData of this.emojis) {
const icon = iconData[0];
let button = document.createXULElement('toolbarbutton'); let button = document.createXULElement('toolbarbutton');
button.className = 'toolbarbutton-1 workspace-icon-button'; button.className = 'toolbarbutton-1 workspace-icon-button';
button.setAttribute('label', icon); button.setAttribute('label', icon);
@@ -621,7 +618,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
let parentPanel = document.getElementById('PanelUI-zen-workspaces-multiview'); let parentPanel = document.getElementById('PanelUI-zen-workspaces-multiview');
// randomly select an icon // randomly select an icon
let icon = this._kIcons[Math.floor(Math.random() * this._kIcons.length)]; let icon = this.emojis[Math.floor(Math.random() * this.emojis.length)][0];
this._workspaceCreateInput.textContent = ''; this._workspaceCreateInput.textContent = '';
this._workspaceCreateInput.value = ''; this._workspaceCreateInput.value = '';
this._workspaceCreateInput.setAttribute('data-initial-value', ''); this._workspaceCreateInput.setAttribute('data-initial-value', '');