mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 00:56:02 +00:00
SYNC: resize heights
This commit is contained in:
committed by
Diflow
parent
438f9fc94d
commit
90d3016938
@@ -14,9 +14,9 @@
|
|||||||
// const widgetColumnBarHeight = writable(0);
|
// const widgetColumnBarHeight = writable(0);
|
||||||
const widgetColumnBarComputed = writable({});
|
const widgetColumnBarComputed = writable({});
|
||||||
const fromStorage = getLocalStorage(storageName);
|
const fromStorage = getLocalStorage(storageName);
|
||||||
let deltaHeights = fromStorage?.deltaHeights || {};
|
let resizedHeights = fromStorage?.resizedHeights || {};
|
||||||
|
|
||||||
$: setLocalStorage(storageName, { deltaHeights });
|
$: setLocalStorage(storageName, { resizedHeights });
|
||||||
|
|
||||||
// setContext('widgetColumnBarHeight', widgetColumnBarHeight);
|
// setContext('widgetColumnBarHeight', widgetColumnBarHeight);
|
||||||
setContext('pushWidgetItemDefinition', (name, item) => {
|
setContext('pushWidgetItemDefinition', (name, item) => {
|
||||||
@@ -37,10 +37,10 @@
|
|||||||
[name]: { ...definitions[name], ...item },
|
[name]: { ...definitions[name], ...item },
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
setContext('widgetResizeItem', (name, deltaHeight) => {
|
setContext('widgetResizeItem', (name, newHeight) => {
|
||||||
deltaHeights = {
|
resizedHeights = {
|
||||||
...deltaHeights,
|
...resizedHeights,
|
||||||
[name]: (deltaHeights[name] || 0) + deltaHeight,
|
[name]: newHeight,
|
||||||
};
|
};
|
||||||
recompute(definitions);
|
recompute(definitions);
|
||||||
});
|
});
|
||||||
@@ -74,7 +74,7 @@
|
|||||||
height = (clientHeight * parseFloat(def.height.slice(0, -1))) / 100;
|
height = (clientHeight * parseFloat(def.height.slice(0, -1))) / 100;
|
||||||
else height = parseInt(def.height);
|
else height = parseInt(def.height);
|
||||||
|
|
||||||
height = Math.max(height, minHeight) + (deltaHeights[key] || 0);
|
if (key in resizedHeights) height = resizedHeights[key];
|
||||||
if (height < minHeight) height = minHeight;
|
if (height < minHeight) height = minHeight;
|
||||||
itemHeights[key] = height;
|
itemHeights[key] = height;
|
||||||
totalFixedHeight += height;
|
totalFixedHeight += height;
|
||||||
@@ -103,6 +103,19 @@
|
|||||||
itemHeights[key] = itemHeights[key] * ratio;
|
itemHeights[key] = itemHeights[key] * ratio;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// third pass - overwrite with resized heights
|
||||||
|
for (const key of visibleItems) {
|
||||||
|
if (key in resizedHeights) {
|
||||||
|
itemHeights[key] = resizedHeights[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// fix total height again
|
||||||
|
const ratio2 = clientHeight / _.sum(Object.values(itemHeights));
|
||||||
|
for (const key of visibleItems) {
|
||||||
|
itemHeights[key] = itemHeights[key] * ratio2;
|
||||||
|
}
|
||||||
|
|
||||||
// Build computed result
|
// Build computed result
|
||||||
let visibleIndex = 0;
|
let visibleIndex = 0;
|
||||||
for (const key of visibleItems) {
|
for (const key of visibleItems) {
|
||||||
@@ -116,6 +129,13 @@
|
|||||||
|
|
||||||
// console.log('WidgetColumnBar definitions', defs);
|
// console.log('WidgetColumnBar definitions', defs);
|
||||||
// console.log('WidgetColumnBar recompute', computed);
|
// console.log('WidgetColumnBar recompute', computed);
|
||||||
|
resizedHeights = _.pickBy(
|
||||||
|
_.mapValues(resizedHeights, (v, k) => {
|
||||||
|
if (k in itemHeights) return v;
|
||||||
|
return undefined;
|
||||||
|
}),
|
||||||
|
v => v != null
|
||||||
|
);
|
||||||
$widgetColumnBarComputed = computed;
|
$widgetColumnBarComputed = computed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -78,7 +78,7 @@
|
|||||||
<div
|
<div
|
||||||
class="vertical-split-handle"
|
class="vertical-split-handle"
|
||||||
use:splitterDrag={'clientY'}
|
use:splitterDrag={'clientY'}
|
||||||
on:resizeSplitter={e => widgetResizeItem(name, e.detail)}
|
on:resizeSplitter={e => widgetResizeItem(name, size + e.detail)}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
Reference in New Issue
Block a user