horizontal splitter improved

This commit is contained in:
SPRINX0\prochazka
2024-11-18 09:25:58 +01:00
parent 534deff274
commit b1893234c7

View File

@@ -1,8 +1,11 @@
<script context="module"> <script context="module">
export function computeSplitterSize(initialValue, clientSize, customRatio) { export function computeSplitterSize(initialValue, clientSize, customRatio, initialSizeRight) {
if (customRatio != null) { if (customRatio != null) {
return clientSize * customRatio; return clientSize * customRatio;
} }
if (initialSizeRight) {
return clientSize - initialSizeRight;
}
if (_.isString(initialValue) && initialValue.startsWith('~') && initialValue.endsWith('px')) if (_.isString(initialValue) && initialValue.startsWith('~') && initialValue.endsWith('px'))
return clientSize - parseInt(initialValue.slice(1, -2)); return clientSize - parseInt(initialValue.slice(1, -2));
if (_.isString(initialValue) && initialValue.endsWith('px')) return parseInt(initialValue.slice(0, -2)); if (_.isString(initialValue) && initialValue.endsWith('px')) return parseInt(initialValue.slice(0, -2));
@@ -20,6 +23,7 @@
export let isSplitter = true; export let isSplitter = true;
export let initialValue = undefined; export let initialValue = undefined;
export let initialSizeRight = undefined;
export let hideFirst = false; export let hideFirst = false;
export let allowCollapseChild1 = false; export let allowCollapseChild1 = false;
@@ -32,7 +36,7 @@
let clientWidth; let clientWidth;
let customRatio = null; let customRatio = null;
$: size = computeSplitterSize(initialValue, clientWidth, customRatio); $: size = computeSplitterSize(initialValue, clientWidth, customRatio, initialSizeRight);
</script> </script>
<div class="container" bind:clientWidth> <div class="container" bind:clientWidth>