Made so split view can be rearranged without ctrl button event

This commit is contained in:
mr. m
2025-03-03 01:18:03 +01:00
parent 8aaccf06b2
commit 7440f12117
2 changed files with 18 additions and 17 deletions

View File

@@ -17,7 +17,7 @@
margin: 0; margin: 0;
} }
#zen-splitview-dropzone { #zen-splitview-dropzone {
border-radius: var(--zen-webview-border-radius, var(--zen-border-radius)); border-radius: var(--zen-native-inner-radius);
transition: inset ease-out 0.08s; transition: inset ease-out 0.08s;
display: none; display: none;
background-color: color-mix(in srgb, var(--zen-colors-secondary) 30%, transparent 70%); background-color: color-mix(in srgb, var(--zen-colors-secondary) 30%, transparent 70%);

View File

@@ -167,7 +167,6 @@ class ZenViewSplitter extends ZenDOMOperatedFeature {
onBrowserDragOverToSplit(event) { onBrowserDragOverToSplit(event) {
var dt = event.dataTransfer; var dt = event.dataTransfer;
const dragEffect = dt.dropEffect;
var draggedTab; var draggedTab;
if (dt.mozTypesAt(0)[0] == TAB_DROP_TYPE) { if (dt.mozTypesAt(0)[0] == TAB_DROP_TYPE) {
// tab copy or move // tab copy or move
@@ -190,11 +189,11 @@ class ZenViewSplitter extends ZenDOMOperatedFeature {
} }
const oldTab = this._lastOpenedTab; const oldTab = this._lastOpenedTab;
this._canDrop = true; this._canDrop = true;
// wait some time before showing the split view
this._showSplitViewTimeout = setTimeout(() => {
this._draggingTab = draggedTab; this._draggingTab = draggedTab;
gBrowser.selectedTab = oldTab; gBrowser.selectedTab = oldTab;
draggedTab._visuallySelected = true; draggedTab._visuallySelected = true;
// wait some time before showing the split view
this._showSplitViewTimeout = setTimeout(() => {
this._hasAnimated = true; this._hasAnimated = true;
const panelsWidth = gBrowser.tabbox.getBoundingClientRect().width; const panelsWidth = gBrowser.tabbox.getBoundingClientRect().width;
const halfWidth = panelsWidth / 2; const halfWidth = panelsWidth / 2;
@@ -235,23 +234,22 @@ class ZenViewSplitter extends ZenDOMOperatedFeature {
return; return;
} }
const panelsRect = gBrowser.tabbox.getBoundingClientRect(); const panelsRect = gBrowser.tabbox.getBoundingClientRect();
// this event is fired even though we are still in the "allowed" area
if (event.target !== gBrowser.tabbox && event.target !== this.fakeBrowser) { if (event.target !== gBrowser.tabbox && event.target !== this.fakeBrowser) {
return; return;
} }
this._canDrop = false;
gBrowser.selectedTab = this._draggingTab;
this._draggingTab = null;
if (this._showSplitViewTimeout) { if (this._showSplitViewTimeout) {
clearTimeout(this._showSplitViewTimeout); clearTimeout(this._showSplitViewTimeout);
} }
if (!this._hasAnimated) { if (!this._hasAnimated || !this.fakeBrowser) {
return; return;
} }
setTimeout(() => { setTimeout(() => {
const panelsWidth = panelsRect.width; const panelsWidth = panelsRect.width;
const halfWidth = panelsWidth / 2; const halfWidth = panelsWidth / 2;
const padding = Services.prefs.getIntPref('zen.theme.content-element-separation', 0); const padding = Services.prefs.getIntPref('zen.theme.content-element-separation', 0);
if (!this.fakeBrowser) {
return;
}
Promise.all([ Promise.all([
gZenUIManager.motion.animate( gZenUIManager.motion.animate(
gBrowser.tabbox, gBrowser.tabbox,
@@ -275,7 +273,10 @@ class ZenViewSplitter extends ZenDOMOperatedFeature {
} }
), ),
]).then(() => { ]).then(() => {
this._mayabeRemoveFakeBrowser(); this._canDrop = false;
gBrowser.selectedTab = this._draggingTab;
this._draggingTab = null;
this._maybeRemoveFakeBrowser();
}); });
}, 100); }, 100);
} }
@@ -837,7 +838,7 @@ class ZenViewSplitter extends ZenDOMOperatedFeature {
this.updateSplitView(tab); this.updateSplitView(tab);
tab.linkedBrowser.docShellIsActive = true; tab.linkedBrowser.docShellIsActive = true;
} }
this._mayabeRemoveFakeBrowser(); this._maybeRemoveFakeBrowser();
} }
/** /**
@@ -1433,13 +1434,12 @@ class ZenViewSplitter extends ZenDOMOperatedFeature {
} }
}; };
_mayabeRemoveFakeBrowser() { _maybeRemoveFakeBrowser() {
gBrowser.tabbox.removeAttribute('style');
if (this.fakeBrowser) { if (this.fakeBrowser) {
delete this._hasAnimated;
this.fakeBrowser.remove(); this.fakeBrowser.remove();
this.fakeBrowser = null; this.fakeBrowser = null;
gBrowser.tabbox.removeAttribute('style');
delete this._canDrop;
delete this._hasAnimated;
gBrowser.selectedTab = this._draggingTab; gBrowser.selectedTab = this._draggingTab;
this._draggingTab = null; this._draggingTab = null;
} }
@@ -1453,7 +1453,8 @@ class ZenViewSplitter extends ZenDOMOperatedFeature {
*/ */
moveTabToSplitView(event, draggedTab) { moveTabToSplitView(event, draggedTab) {
const canDrop = this._canDrop; const canDrop = this._canDrop;
this._mayabeRemoveFakeBrowser(); this._maybeRemoveFakeBrowser();
this._canDrop = false;
if (!canDrop) { if (!canDrop) {
return false; return false;
} }