mirror of
https://github.com/zadam/trilium.git
synced 2025-12-20 22:34:23 +01:00
chore(right_pane): basic expand support
This commit is contained in:
parent
682c61305c
commit
5dacfd3ac6
@ -51,6 +51,8 @@ export default function RightPanelContainer() {
|
|||||||
return () => splitInstance.destroy();
|
return () => splitInstance.destroy();
|
||||||
}, [ items ]);
|
}, [ items ]);
|
||||||
|
|
||||||
|
const sizesBeforeCollapse = useRef(new WeakMap<HTMLElement, number>());
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div id="right-pane">
|
<div id="right-pane">
|
||||||
<RightPanelContext.Provider value={{
|
<RightPanelContext.Provider value={{
|
||||||
@ -65,12 +67,21 @@ export default function RightPanelContainer() {
|
|||||||
const sizes = splitInstance.getSizes();
|
const sizes = splitInstance.getSizes();
|
||||||
if (!expanded) {
|
if (!expanded) {
|
||||||
const sizeBeforeCollapse = sizes[pos];
|
const sizeBeforeCollapse = sizes[pos];
|
||||||
|
sizesBeforeCollapse.current.set(cardEl, sizeBeforeCollapse);
|
||||||
sizes[pos] = 0;
|
sizes[pos] = 0;
|
||||||
const itemToExpand = pos > 0 ? pos - 1 : pos + 1;
|
const itemToExpand = pos > 0 ? pos - 1 : pos + 1;
|
||||||
|
|
||||||
if (sizes[itemToExpand] > COLLAPSED_SIZE) {
|
if (sizes[itemToExpand] > COLLAPSED_SIZE) {
|
||||||
sizes[itemToExpand] += sizeBeforeCollapse;
|
sizes[itemToExpand] += sizeBeforeCollapse;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
const itemToExpand = pos > 0 ? pos - 1 : pos + 1;
|
||||||
|
const sizeBeforeCollapse = sizesBeforeCollapse.current.get(cardEl) ?? 50;
|
||||||
|
|
||||||
|
if (sizes[itemToExpand] > COLLAPSED_SIZE) {
|
||||||
|
sizes[itemToExpand] -= sizeBeforeCollapse;
|
||||||
|
}
|
||||||
|
sizes[pos] = sizeBeforeCollapse;
|
||||||
}
|
}
|
||||||
console.log("Set sizes to ", sizes);
|
console.log("Set sizes to ", sizes);
|
||||||
splitInstance.setSizes(sizes);
|
splitInstance.setSizes(sizes);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user