diff --git a/app/src/layout/dock/index.ts b/app/src/layout/dock/index.ts index a22dc2c8d..5a879c52c 100644 --- a/app/src/layout/dock/index.ts +++ b/app/src/layout/dock/index.ts @@ -86,11 +86,20 @@ export class Dock { break; } else if (target.classList.contains("dock__item")) { this.pin = !target.classList.contains("dock__item--pin"); + const hasActive = this.element.querySelector(".dock__item--active"); if (!this.pin) { if (this.position === "Left" || this.position === "Right") { - this.layout.element.setAttribute("style", `width:${this.layout.element.clientWidth}px;${this.position === "Right" ? "right" : "left"}:${this.element.clientWidth + .5}px; top: ${.5 + document.getElementById("toolbar").clientHeight + document.getElementById("dockTop").clientHeight}px; bottom: ${document.getElementById("status").clientHeight + document.getElementById("dockBottom").clientHeight + .5}px;`); + this.layout.element.setAttribute("style", `width:${this.layout.element.clientWidth}px; +opacity: ${hasActive?1:0}; +${this.position === "Right" ? "right" : "left"}:${this.element.clientWidth + .5}px; +top: ${.5 + document.getElementById("toolbar").clientHeight + document.getElementById("dockTop").clientHeight}px; +bottom: ${document.getElementById("status").clientHeight + document.getElementById("dockBottom").clientHeight + 1}px;`); } else { - this.layout.element.setAttribute("style", `height:${this.layout.element.clientHeight}px;left:0;right:0;${this.position === "Top" ? ("top:" + (.5 + this.element.clientHeight + document.getElementById("toolbar").clientHeight) + "px") : ("bottom:" + (.5 + this.element.clientHeight + document.getElementById("status").clientHeight) + "px")};`); + this.layout.element.setAttribute("style", `height:${this.layout.element.clientHeight}px; +opacity: ${hasActive?1:0}; +left:0; +right:0; +${this.position === "Top" ? ("top:" + (.5 + this.element.clientHeight + document.getElementById("toolbar").clientHeight) + "px") : ("bottom:" + (1 + this.element.clientHeight + document.getElementById("status").clientHeight) + "px")};`); } target.setAttribute("aria-label", window.siyuan.languages.pin); } else { @@ -98,7 +107,13 @@ export class Dock { } target.classList.toggle("dock__item--pin"); this.layout.element.classList.toggle("layout--float"); - this.resizeElement.classList.toggle("fn__none"); + if (this.pin) { + if (hasActive) { + this.resizeElement.classList.remove("fn__none"); + } + } else { + this.resizeElement.classList.add("fn__none"); + } event.preventDefault(); break; } @@ -129,9 +144,17 @@ export class Dock { if (!this.pin) { setTimeout(() => { if (this.position === "Left" || this.position === "Right") { - this.layout.element.setAttribute("style", `opacity:0px;width:${this.layout.element.clientWidth}px;${this.position === "Right" ? "right" : "left"}:-${this.layout.element.clientWidth}px; top: ${.5 + document.getElementById("toolbar").clientHeight + document.getElementById("dockTop").clientHeight}px; bottom: ${document.getElementById("status").clientHeight + document.getElementById("dockBottom").clientHeight + .5}px;`); + this.layout.element.setAttribute("style", `opacity:0px; +width:${this.layout.element.clientWidth}px;${this.position === "Right" ? "right" : "left"}:-${this.layout.element.clientWidth}px; +top: ${.5 + document.getElementById("toolbar").clientHeight + document.getElementById("dockTop").clientHeight}px; +bottom: ${document.getElementById("status").clientHeight + document.getElementById("dockBottom").clientHeight + 1}px;`); } else { - this.layout.element.setAttribute("style", `opacity:0px;height:${this.layout.element.clientHeight}px;left:0;right:0;${this.position === "Top" ? "top" : "bottom"}:-${this.layout.element.clientHeight}px;`); + this.layout.element.setAttribute("style", ` +opacity:0px; +height:${this.layout.element.clientHeight}px; +left:0; +right:0; +${this.position === "Top" ? "top" : "bottom"}:-${this.layout.element.clientHeight}px;`); } this.layout.element.classList.add("layout--float"); this.resizeElement.classList.add("fn__none"); @@ -311,7 +334,9 @@ export class Dock { document.querySelector("body").classList.contains("body--win32") && this.layout.element.querySelector(".fullscreen")) { document.getElementById("drag").classList.add("fn__hidden"); } - this.resizeElement.classList.remove("fn__none"); + if (this.pin) { + this.resizeElement.classList.remove("fn__none"); + } } // dock 中两个面板的显示关系 diff --git a/app/src/layout/dock/util.ts b/app/src/layout/dock/util.ts index c97905d6b..fb955fe24 100644 --- a/app/src/layout/dock/util.ts +++ b/app/src/layout/dock/util.ts @@ -89,14 +89,14 @@ export const openOutline = (protyle: IProtyle) => { export const resetFloatDockSize = () => { if (!window.siyuan.layout.leftDock.pin) { window.siyuan.layout.leftDock.layout.element.style.top = (.5 + document.getElementById("toolbar").clientHeight + document.getElementById("dockTop").clientHeight) + "px"; - window.siyuan.layout.leftDock.layout.element.style.bottom = (document.getElementById("status").clientHeight + document.getElementById("dockBottom").clientHeight + .5) + "px"; + window.siyuan.layout.leftDock.layout.element.style.bottom = (document.getElementById("status").clientHeight + document.getElementById("dockBottom").clientHeight + 1) + "px"; if (window.siyuan.layout.leftDock.layout.element.style.opacity === "1") { window.siyuan.layout.leftDock.layout.element.style.left = (window.siyuan.layout.leftDock.element.clientWidth + .5) + "px"; } } if (!window.siyuan.layout.rightDock.pin) { window.siyuan.layout.rightDock.layout.element.style.top = (.5 + document.getElementById("toolbar").clientHeight + document.getElementById("dockTop").clientHeight) + "px"; - window.siyuan.layout.rightDock.layout.element.style.bottom = (document.getElementById("status").clientHeight + document.getElementById("dockBottom").clientHeight + .5) + "px"; + window.siyuan.layout.rightDock.layout.element.style.bottom = (document.getElementById("status").clientHeight + document.getElementById("dockBottom").clientHeight + 1) + "px"; if (window.siyuan.layout.rightDock.layout.element.style.opacity === "1") { window.siyuan.layout.rightDock.layout.element.style.right = (window.siyuan.layout.rightDock.element.clientWidth + .5) + "px"; } @@ -105,6 +105,6 @@ export const resetFloatDockSize = () => { window.siyuan.layout.topDock.layout.element.style.top = (document.getElementById("dockTop").clientHeight + document.getElementById("toolbar").clientHeight + .5) + "px"; } if (!window.siyuan.layout.bottomDock.pin && window.siyuan.layout.bottomDock.layout.element.style.opacity === "1") { - window.siyuan.layout.bottomDock.layout.element.style.bottom = (document.getElementById("dockBottom").clientHeight + document.getElementById("status").clientHeight + .5) + "px"; + window.siyuan.layout.bottomDock.layout.element.style.bottom = (document.getElementById("dockBottom").clientHeight + document.getElementById("status").clientHeight + 1) + "px"; } }; diff --git a/app/src/util/globalShortcut.ts b/app/src/util/globalShortcut.ts index e99350d48..d2666dec2 100644 --- a/app/src/util/globalShortcut.ts +++ b/app/src/util/globalShortcut.ts @@ -97,7 +97,7 @@ export const globalShortcut = () => { } if (event.clientX < 43) { - if (!window.siyuan.layout.leftDock.pin) { + if (!window.siyuan.layout.leftDock.pin && window.siyuan.layout.leftDock.layout.element.clientWidth > 0) { if (event.clientY > document.getElementById("toolbar").clientHeight + document.getElementById("dockTop").clientHeight && event.clientY < window.innerHeight - document.getElementById("status").clientHeight - document.getElementById("dockBottom").clientHeight) { if (!hasClosestByClassName(event.target as HTMLElement, "b3-menu") && @@ -111,7 +111,7 @@ export const globalShortcut = () => { } } } else if (event.clientX > window.innerWidth - 41) { - if (!window.siyuan.layout.rightDock.pin) { + if (!window.siyuan.layout.rightDock.pin && window.siyuan.layout.rightDock.layout.element.clientWidth > 0) { if (event.clientY > document.getElementById("toolbar").clientHeight + document.getElementById("dockTop").clientHeight && event.clientY < window.innerHeight - document.getElementById("status").clientHeight - document.getElementById("dockBottom").clientHeight) { if (!hasClosestByClassName(event.target as HTMLElement, "layout--float") && window.siyuan.layout.rightDock.layout.element.style.opacity !== "1") { @@ -125,13 +125,13 @@ export const globalShortcut = () => { } if (event.clientY < 75) { - if (!window.siyuan.layout.topDock.pin && window.siyuan.layout.topDock.layout.element.style.opacity !== "1") { + if (!window.siyuan.layout.topDock.pin && window.siyuan.layout.topDock.layout.element.clientHeight > 0 && window.siyuan.layout.topDock.layout.element.style.opacity !== "1") { window.siyuan.layout.topDock.layout.element.style.top = (document.getElementById("dockTop").clientHeight + document.getElementById("toolbar").clientHeight + .5) + "px"; window.siyuan.layout.topDock.layout.element.style.opacity = "1"; } } else if (event.clientY > window.innerHeight - 73) { - if (!window.siyuan.layout.bottomDock.pin && window.siyuan.layout.bottomDock.layout.element.style.opacity !== "1") { - window.siyuan.layout.bottomDock.layout.element.style.bottom = (document.getElementById("dockBottom").clientHeight + document.getElementById("status").clientHeight + .5) + "px"; + if (!window.siyuan.layout.bottomDock.pin && window.siyuan.layout.bottomDock.layout.element.clientHeight > 0 && window.siyuan.layout.bottomDock.layout.element.style.opacity !== "1") { + window.siyuan.layout.bottomDock.layout.element.style.bottom = (document.getElementById("dockBottom").clientHeight + document.getElementById("status").clientHeight + 1) + "px"; window.siyuan.layout.bottomDock.layout.element.style.opacity = "1"; } }