Skip to content

Commit

Permalink
Improve resizing on scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
myieye committed Nov 19, 2024
1 parent fede04b commit 3f3c556
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
10 changes: 9 additions & 1 deletion frontend/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/viewer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"@microsoft/signalr": "^8.0.0",
"autoprefixer": "^10.4.19",
"fast-json-patch": "^3.1.1",
"just-throttle": "^4.2.0",
"postcss": "catalog:",
"svelte-exmarkdown": "^3.0.5",
"svelte-preprocess": "catalog:",
Expand Down
5 changes: 3 additions & 2 deletions frontend/viewer/src/ProjectView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import {useEventBus} from './lib/services/event-bus';
import AboutDialog from './lib/about/AboutDialog.svelte';
import { initProjectCommands, type NewEntryDialogOptions } from './lib/commands';
import throttle from 'just-throttle';
export let loading = false;
Expand Down Expand Up @@ -229,11 +230,11 @@
let editorElem: HTMLElement | undefined;
let spaceForEditorStyle: string = '';
const updateSpaceForEditor = makeDebouncer(() => {
const updateSpaceForEditor = throttle(() => {
if (!editorElem) return;
const availableHeight = getAvailableHeightForElement(editorElem);
spaceForEditorStyle = `--space-for-editor: ${availableHeight}px`;
}, 30).debounce;
}, 20, { leading: false, trailing: true });
$: editorElem && updateSpaceForEditor();
onMount(() => {
Expand Down
2 changes: 1 addition & 1 deletion frontend/viewer/src/app.postcss
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

.side-scroller {
height: calc(var(--space-for-editor, 100vh) - 32px);
transition: height 0.1s ease-out, opacity 0.2s ease-out;
transition: height 0.05s ease-out, opacity 0.2s ease-out;
position: sticky;
top: 16px;
}
Expand Down

0 comments on commit 3f3c556

Please sign in to comment.