|
68 | 68 | class nsZenPinnedTabManager extends nsZenDOMOperatedFeature {
|
69 | 69 | MAX_ESSENTIALS_TABS = 12;
|
70 | 70 |
|
| 71 | + #hasInitializedPins = false; |
| 72 | + |
71 | 73 | async init() {
|
72 | 74 | if (!this.enabled) {
|
73 | 75 | return;
|
|
351 | 353 |
|
352 | 354 | gBrowser._updateTabBarForPinnedTabs();
|
353 | 355 | gZenUIManager.updateTabsToolbar();
|
| 356 | + |
| 357 | + setTimeout(() => { |
| 358 | + this.#hasInitializedPins = true; |
| 359 | + }, 0); |
354 | 360 | }
|
355 | 361 |
|
356 | 362 | _onPinnedTabEvent(action, event) {
|
|
693 | 699 | }
|
694 | 700 |
|
695 | 701 | async savePin(pin, notifyObservers = true) {
|
| 702 | + if (!this.#hasInitializedPins) { |
| 703 | + return; |
| 704 | + } |
696 | 705 | const existingPin = this._pinsCache.find((p) => p.uuid === pin.uuid);
|
697 | 706 | if (existingPin) {
|
698 | 707 | Object.assign(existingPin, pin);
|
|
1163 | 1172 | : [separator];
|
1164 | 1173 | }
|
1165 | 1174 |
|
1166 |
| - animateSeparatorMove(draggedTab, dropElement, isPinned) { |
| 1175 | + animateSeparatorMove(draggedTab, dropElement, isPinned, event) { |
1167 | 1176 | if (draggedTab?.group?.hasAttribute('split-view-group')) {
|
1168 | 1177 | draggedTab = draggedTab.group;
|
1169 | 1178 | }
|
1170 | 1179 | const itemsToCheck = this.dragShiftableItems;
|
1171 |
| - const separatorHeight = window.windowUtils.getBoundsWithoutFlushing(itemsToCheck[0]).height; |
1172 |
| - const tabRect = window.windowUtils.getBoundsWithoutFlushing(draggedTab); |
1173 |
| - const translate = tabRect.top - tabRect.height / 2; |
1174 |
| - const topToNormalTabs = |
1175 |
| - window.windowUtils.getBoundsWithoutFlushing(itemsToCheck[0]).top - separatorHeight / 2; |
| 1180 | + const translate = event.screenY; |
| 1181 | + const draggingTabHeight = window.windowUtils.getBoundsWithoutFlushing(draggedTab).height; |
| 1182 | + let topToNormalTabs = itemsToCheck[0].screenY; |
| 1183 | + if (!isPinned) { |
| 1184 | + topToNormalTabs += draggedTab.getBoundingClientRect().height; |
| 1185 | + } |
1176 | 1186 | const isGoingToPinnedTabs = translate < topToNormalTabs;
|
1177 | 1187 | const multiplier = isGoingToPinnedTabs !== isPinned ? (isGoingToPinnedTabs ? 1 : -1) : 0;
|
1178 |
| - const draggingTabHeight = |
1179 |
| - window.windowUtils.getBoundsWithoutFlushing(draggedTab).height * multiplier; |
1180 | 1188 | this._isGoingToPinnedTabs = isGoingToPinnedTabs;
|
1181 | 1189 | if (!dropElement) {
|
1182 | 1190 | itemsToCheck.forEach((item) => {
|
1183 |
| - item.style.transform = `translateY(${draggingTabHeight}px)`; |
| 1191 | + item.style.transform = `translateY(${draggingTabHeight * multiplier}px)`; |
1184 | 1192 | });
|
1185 | 1193 | }
|
1186 | 1194 | }
|
|
0 commit comments