Skip to content

Commit 746ba02

Browse files
committed
Make drawer resizing a bit nore intuitive
Interpret height = scroll height as a reset, it feels more intuitive this way.
1 parent ccba63e commit 746ba02

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

apps/desktop/src/components/Drawer.svelte

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,19 @@
7373
let headerHeight = $state(0);
7474
let contentHeight = $state(0);
7575
const totalHeightRem = $derived(pxToRem(headerHeight + contentHeight, zoom));
76+
77+
let resizerInstance = $state<Resizer>();
78+
$effect(() => {
79+
// Reset resizer if we happen on a value that equals the scroll
80+
// height, enabling the user to more easily undo manual sizing. It
81+
// is assumed that an unset value makes the element display in
82+
// full, otherwise there would be sudden content shift.
83+
if (clientHeight === headerHeight + contentHeight) {
84+
requestAnimationFrame(() => {
85+
resizerInstance?.setValue(undefined);
86+
});
87+
}
88+
});
7689
</script>
7790

7891
<div
@@ -155,6 +168,7 @@
155168
{/if}
156169
{#if resizer}
157170
<Resizer
171+
bind:this={resizerInstance}
158172
defaultValue={undefined}
159173
viewport={containerDiv}
160174
hidden={$collapsed}

apps/desktop/src/components/Resizer.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@
243243
return pxToRem(viewport.clientHeight, zoom);
244244
}
245245
246-
function setValue(newSize?: number) {
246+
export function setValue(newSize?: number) {
247247
value.set(newSize);
248248
updateDom(newSize);
249249
if (newSize !== undefined) {

0 commit comments

Comments
 (0)