simplify Divide component to only set total on mousedown on divider
This commit is contained in:
parent
8679ecb1f8
commit
3ca66d6958
|
@ -30,21 +30,14 @@ $: style = s({
|
||||||
'--divide-min-height': minSize > 0 && mode === 'v' ? `${minSize}px` : '0',
|
'--divide-min-height': minSize > 0 && mode === 'v' ? `${minSize}px` : '0',
|
||||||
});
|
});
|
||||||
|
|
||||||
onMount(() => {
|
|
||||||
total = getTotal();
|
|
||||||
});
|
|
||||||
|
|
||||||
function getTotal() {
|
function getTotal() {
|
||||||
return mode === 'h' ? divide.clientWidth : divide.clientHeight;
|
return mode === 'h' ? divide.clientWidth : divide.clientHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleResize() {
|
|
||||||
total = getTotal();
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleMousedown(event) {
|
function handleMousedown(event) {
|
||||||
if (event.button === 0) {
|
if (event.button === 0) {
|
||||||
dragging = true;
|
dragging = true;
|
||||||
|
total = getTotal();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,8 +114,6 @@ function handleMouseenter(event) {
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<svelte:window on:resize="{handleResize}" />
|
|
||||||
|
|
||||||
<div
|
<div
|
||||||
class="{classes}"
|
class="{classes}"
|
||||||
{style}
|
{style}
|
||||||
|
|
Loading…
Reference in New Issue