Vanessa 2023-02-15 18:54:57 +08:00
parent 23f83b3665
commit 40fd9325c5

View file

@ -598,7 +598,9 @@ export const getInstanceById = (id: string, layout = window.siyuan.layout.center
};
export const addResize = (obj: Layout | Wnd) => {
if (obj.resize) {
if (!obj.resize) {
return
}
const resizeWnd = (resizeElement: HTMLElement, direction: string) => {
const setSize = (item: HTMLElement, direction: string) => {
if (item.classList.contains("fn__flex-1")) {
@ -627,8 +629,16 @@ export const addResize = (obj: Layout | Wnd) => {
const previousElement = resizeElement.previousElementSibling as HTMLElement;
nextElement.style.overflow = "auto"; // 拖动时 layout__resize 会出现 https://github.com/siyuan-note/siyuan/issues/6221
previousElement.style.overflow = "auto";
setSize(nextElement, direction);
if (!nextElement.nextElementSibling) {
if (!previousElement.previousElementSibling) {
setSize(previousElement, direction);
} else {
setSize(nextElement, direction);
}
} else if (nextElement.nextElementSibling?.nextElementSibling &&
nextElement.parentElement.lastElementChild.isSameNode(nextElement.nextElementSibling.nextElementSibling)) {
setSize(previousElement, direction);
}
const x = event[direction === "lr" ? "clientX" : "clientY"];
const previousSize = direction === "lr" ? previousElement.clientWidth : previousElement.clientHeight;
const nextSize = direction === "lr" ? nextElement.clientWidth : nextElement.clientHeight;
@ -657,8 +667,12 @@ export const addResize = (obj: Layout | Wnd) => {
if (window.siyuan.layout.rightDock?.layout.element.contains(nextElement) && nextNowSize < 320) {
return;
}
if (!previousElement.classList.contains("fn__flex-1")) {
previousElement.style[direction === "lr" ? "width" : "height"] = previousNowSize + "px";
}
if (!nextElement.classList.contains("fn__flex-1")) {
nextElement.style[direction === "lr" ? "width" : "height"] = nextNowSize + "px";
}
};
documentSelf.onmouseup = () => {
@ -667,20 +681,6 @@ export const addResize = (obj: Layout | Wnd) => {
documentSelf.ondragstart = null;
documentSelf.onselectstart = null;
documentSelf.onselect = null;
if (!nextElement.nextElementSibling) {
if (!previousElement.previousElementSibling) {
nextElement.style[direction === "lr" ? "width" : "height"] = "";
nextElement.classList.add("fn__flex-1");
} else {
previousElement.style[direction === "lr" ? "width" : "height"] = "";
previousElement.classList.add("fn__flex-1");
}
} else if (nextElement.nextElementSibling?.nextElementSibling &&
nextElement.parentElement.lastElementChild.isSameNode(nextElement.nextElementSibling.nextElementSibling)) {
nextElement.style[direction === "lr" ? "width" : "height"] = "";
nextElement.classList.add("fn__flex-1");
}
resizeTabs();
if (!isWindow()) {
window.siyuan.layout.leftDock.setSize();
@ -704,7 +704,6 @@ export const addResize = (obj: Layout | Wnd) => {
resizeElement.classList.add("layout__resize");
obj.element.insertAdjacentElement("beforebegin", resizeElement);
resizeWnd(resizeElement, obj.resize);
}
};
export const newCenterEmptyTab = () => {