mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-01 15:33:57 +00:00
fixed Resizing window resets window contents #479
This commit is contained in:
@@ -1,5 +1,8 @@
|
|||||||
<script context="module">
|
<script context="module">
|
||||||
export function computeSplitterSize(initialValue, clientSize) {
|
export function computeSplitterSize(initialValue, clientSize, customRatio) {
|
||||||
|
if (customRatio != null) {
|
||||||
|
return clientSize * customRatio;
|
||||||
|
}
|
||||||
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));
|
||||||
@@ -27,8 +30,9 @@
|
|||||||
|
|
||||||
export let size = 0;
|
export let size = 0;
|
||||||
let clientWidth;
|
let clientWidth;
|
||||||
|
let customRatio = null;
|
||||||
|
|
||||||
$: size = computeSplitterSize(initialValue, clientWidth);
|
$: size = computeSplitterSize(initialValue, clientWidth, customRatio);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="container" bind:clientWidth>
|
<div class="container" bind:clientWidth>
|
||||||
@@ -52,7 +56,10 @@
|
|||||||
class="horizontal-split-handle"
|
class="horizontal-split-handle"
|
||||||
style={collapsed1 || collapsed2 ? 'display:none' : ''}
|
style={collapsed1 || collapsed2 ? 'display:none' : ''}
|
||||||
use:splitterDrag={'clientX'}
|
use:splitterDrag={'clientX'}
|
||||||
on:resizeSplitter={e => (size += e.detail)}
|
on:resizeSplitter={e => {
|
||||||
|
size += e.detail;
|
||||||
|
if (clientWidth > 0) customRatio = size / clientWidth;
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -16,8 +16,9 @@
|
|||||||
|
|
||||||
let collapsed1 = false;
|
let collapsed1 = false;
|
||||||
let collapsed2 = false;
|
let collapsed2 = false;
|
||||||
|
let customRatio = null;
|
||||||
|
|
||||||
$: size = computeSplitterSize(initialValue, clientHeight);
|
$: size = computeSplitterSize(initialValue, clientHeight, customRatio);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="container" bind:clientHeight>
|
<div class="container" bind:clientHeight>
|
||||||
@@ -38,7 +39,10 @@
|
|||||||
class={'vertical-split-handle'}
|
class={'vertical-split-handle'}
|
||||||
style={collapsed1 || collapsed2 ? 'display:none' : ''}
|
style={collapsed1 || collapsed2 ? 'display:none' : ''}
|
||||||
use:splitterDrag={'clientY'}
|
use:splitterDrag={'clientY'}
|
||||||
on:resizeSplitter={e => (size += e.detail)}
|
on:resizeSplitter={e => {
|
||||||
|
size += e.detail;
|
||||||
|
if (clientHeight > 0) customRatio = size / clientHeight;
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
class={collapsed1 ? 'child1' : 'child2'}
|
class={collapsed1 ? 'child1' : 'child2'}
|
||||||
|
|||||||
Reference in New Issue
Block a user