aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2022-12-14 17:20:36 +0100
committerLibravatar Kristóf Marussy <kristof@marussy.com>2022-12-21 18:34:11 +0100
commit5ec18ba043768208dbeacfe0b0c8acf53c81736a (patch)
treeb881378b32341ccedfb852b2629c9a54c6eb71fe
parentfeat(frontend): add links to top bar (diff)
downloadrefinery-5ec18ba043768208dbeacfe0b0c8acf53c81736a.tar.gz
refinery-5ec18ba043768208dbeacfe0b0c8acf53c81736a.tar.zst
refinery-5ec18ba043768208dbeacfe0b0c8acf53c81736a.zip
fix(frontend): do not scroll initially
Make sure the CodeMirror DOM is fully ready before inserting a spacer element for overscroll behavior.
-rw-r--r--subprojects/frontend/src/editor/scrollbarViewPlugin.ts15
1 files changed, 14 insertions, 1 deletions
diff --git a/subprojects/frontend/src/editor/scrollbarViewPlugin.ts b/subprojects/frontend/src/editor/scrollbarViewPlugin.ts
index 8f165e89..f54251a9 100644
--- a/subprojects/frontend/src/editor/scrollbarViewPlugin.ts
+++ b/subprojects/frontend/src/editor/scrollbarViewPlugin.ts
@@ -238,6 +238,8 @@ export default function scrollbarViewPlugin(
238 238
239 let gutters: Element | undefined; 239 let gutters: Element | undefined;
240 240
241 let firstRun = true;
242 let firstRunTimeout: number | undefined;
241 let requested = false; 243 let requested = false;
242 let rebuildRequested = false; 244 let rebuildRequested = false;
243 245
@@ -260,7 +262,18 @@ export default function scrollbarViewPlugin(
260 const { scrollTop, scrollLeft, scrollWidth } = scrollDOM; 262 const { scrollTop, scrollLeft, scrollWidth } = scrollDOM;
261 const scrollHeight = 263 const scrollHeight =
262 view.contentHeight + scrollerHeight - view.defaultLineHeight; 264 view.contentHeight + scrollerHeight - view.defaultLineHeight;
263 spacer.style.minHeight = `${scrollHeight}px`; 265 if (firstRun) {
266 if (firstRunTimeout !== undefined) {
267 clearTimeout(firstRunTimeout);
268 }
269 // @ts-expect-error `@types/node` typings should not be in effect here.
270 firstRunTimeout = setTimeout(() => {
271 spacer.style.minHeight = `${scrollHeight}px`;
272 firstRun = false;
273 }, 0);
274 } else {
275 spacer.style.minHeight = `${scrollHeight}px`;
276 }
264 gutterWidth = gutters?.clientWidth ?? 0; 277 gutterWidth = gutters?.clientWidth ?? 0;
265 let trackYHeight = scrollerHeight; 278 let trackYHeight = scrollerHeight;
266 279