mirror of
https://github.com/zen-browser/components.git
synced 2025-07-07 23:49:58 +02:00
Added expand to fullscreen for glance
This commit is contained in:
parent
99003f3cb5
commit
b1b3cb8555
1 changed files with 67 additions and 13 deletions
|
@ -38,6 +38,8 @@
|
||||||
() => document.getElementById('zen-glance-loading')
|
() => document.getElementById('zen-glance-loading')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.originalOverlayParent = this.overlay.parentNode;
|
||||||
|
|
||||||
Services.obs.addObserver(this, "zen-glance-open");
|
Services.obs.addObserver(this, "zen-glance-open");
|
||||||
this.initProgressListener();
|
this.initProgressListener();
|
||||||
}
|
}
|
||||||
|
@ -70,11 +72,13 @@
|
||||||
console.log(url);
|
console.log(url);
|
||||||
const newTabOptions = {
|
const newTabOptions = {
|
||||||
userContextId: currentTab.getAttribute("usercontextid") || "",
|
userContextId: currentTab.getAttribute("usercontextid") || "",
|
||||||
inBackground: true,
|
skipBackgroundNotify: true,
|
||||||
skipLoading: true,
|
bulkOrderedOpen: true,
|
||||||
insertTab: false,
|
insertTab: false,
|
||||||
|
skipLoad: false,
|
||||||
};
|
};
|
||||||
const newTab = gBrowser.addTrustedTab(url, newTabOptions);
|
gBrowser.zenGlanceBrowser = true;
|
||||||
|
const newTab = gBrowser.addTrustedTab(Services.io.newURI(url).spec, newTabOptions);
|
||||||
document.getElementById("zen-glance-tabs").appendChild(newTab);
|
document.getElementById("zen-glance-tabs").appendChild(newTab);
|
||||||
this.#currentBrowser = newTab.linkedBrowser;
|
this.#currentBrowser = newTab.linkedBrowser;
|
||||||
this.#currentTab = newTab;
|
this.#currentTab = newTab;
|
||||||
|
@ -86,25 +90,28 @@
|
||||||
const initialY = data.y;
|
const initialY = data.y;
|
||||||
const initialWidth = data.width;
|
const initialWidth = data.width;
|
||||||
const initialHeight = data.height;
|
const initialHeight = data.height;
|
||||||
|
|
||||||
|
this.browserWrapper.removeAttribute("animate");
|
||||||
|
this.browserWrapper.removeAttribute("animate-end");
|
||||||
|
this.browserWrapper.removeAttribute("animate-full");
|
||||||
|
this.browserWrapper.removeAttribute("animate-full-end");
|
||||||
|
|
||||||
const url = data.url;
|
const url = data.url;
|
||||||
if (this.#currentBrowser) {
|
if (this.#currentBrowser) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const currentTab = gBrowser.selectedTab;
|
const currentTab = gBrowser.selectedTab;
|
||||||
const overlayWrapper = currentTab.linkedBrowser.closest(".browserSidebarContainer");
|
const overlayWrapper = document.getElementById("tabbrowser-tabbox");
|
||||||
overlayWrapper.appendChild(this.overlay);
|
overlayWrapper.prepend(this.overlay);
|
||||||
|
|
||||||
const browserElement = this.createBrowserElement(url, currentTab);
|
const browserElement = this.createBrowserElement(url, currentTab);
|
||||||
this.browser.appendChild(browserElement);
|
browserElement.zenModeActive = true;
|
||||||
|
|
||||||
browserElement.addProgressListener(this.progressListener, Ci.nsIWebProgress.NOTIFY_LOCATION);
|
browserElement.addProgressListener(this.progressListener, Ci.nsIWebProgress.NOTIFY_LOCATION);
|
||||||
|
|
||||||
browserElement.docShellIsActive = true;
|
|
||||||
browserElement.loadURI(Services.io.newURI(url), {
|
browserElement.loadURI(Services.io.newURI(url), {
|
||||||
triggeringPrincipal: Services.scriptSecurityManager.createNullPrincipal(
|
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
|
||||||
{}
|
|
||||||
),
|
|
||||||
});
|
});
|
||||||
|
browserElement.docShellIsActive = true;
|
||||||
|
|
||||||
this.loadingBar.setAttribute("not-loading", true);
|
this.loadingBar.setAttribute("not-loading", true);
|
||||||
this.loadingBar.removeAttribute("loading");
|
this.loadingBar.removeAttribute("loading");
|
||||||
|
@ -127,11 +134,24 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
closeGlance() {
|
closeGlance({ noAnimation = false } = {}) {
|
||||||
if (this.#animating) {
|
if (this.#animating) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (noAnimation) {
|
||||||
|
this.overlay.setAttribute("hidden", true);
|
||||||
|
this.overlay.removeAttribute("fade-out");
|
||||||
|
this.browserWrapper.removeAttribute("animate");
|
||||||
|
this.browserWrapper.removeAttribute("animate-end");
|
||||||
|
this.#currentBrowser?.remove();
|
||||||
|
this.#currentTab?.remove();
|
||||||
|
this.#currentBrowser = null;
|
||||||
|
this.#currentTab = null;
|
||||||
|
this.originalOverlayParent.appendChild(this.overlay);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// do NOT touch here, I don't know what it does, but it works...
|
// do NOT touch here, I don't know what it does, but it works...
|
||||||
window.requestAnimationFrame(() => {
|
window.requestAnimationFrame(() => {
|
||||||
this.browserWrapper.removeAttribute("animate");
|
this.browserWrapper.removeAttribute("animate");
|
||||||
|
@ -149,13 +169,47 @@
|
||||||
this.#currentTab?.remove();
|
this.#currentTab?.remove();
|
||||||
this.#currentBrowser = null;
|
this.#currentBrowser = null;
|
||||||
this.#currentTab = null;
|
this.#currentTab = null;
|
||||||
|
|
||||||
|
this.originalOverlayParent.appendChild(this.overlay);
|
||||||
}, 500);
|
}, 500);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onLocationChange(_) {
|
onLocationChange(_) {
|
||||||
this.closeGlance();
|
if (!this.animatingFullOpen) {
|
||||||
|
this.closeGlance();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fullyOpenGlance() {
|
||||||
|
const newTabOptions = {
|
||||||
|
userContextId: this.#currentTab.getAttribute("usercontextid") || "",
|
||||||
|
skipLoad: true,
|
||||||
|
ownerTab: this.#currentTab,
|
||||||
|
preferredRemoteType: this.#currentTab.linkedBrowser.remoteType,
|
||||||
|
};
|
||||||
|
|
||||||
|
const newTab = gBrowser.duplicateTab(this.#currentTab, true, newTabOptions);
|
||||||
|
|
||||||
|
this.animatingFullOpen = true;
|
||||||
|
|
||||||
|
this.browserWrapper.setAttribute("animate-full", true);
|
||||||
|
setTimeout(() => {
|
||||||
|
window.requestAnimationFrame(() => {
|
||||||
|
this.browserWrapper.setAttribute("animate-full-end", true);
|
||||||
|
window.requestAnimationFrame(() => {
|
||||||
|
gBrowser.selectedTab = newTab;
|
||||||
|
window.requestAnimationFrame(() => {
|
||||||
|
setTimeout(() => {
|
||||||
|
this.animatingFullOpen = false;
|
||||||
|
this.closeGlance({ noAnimation: true });
|
||||||
|
}, 400);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}, 200);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue