From b281e233b35ae1616d4ab43630e2d7c9b6c8790d Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 19 May 2022 21:02:54 +0100 Subject: [PATCH] Scroll preview to the top to show navigation whenever editing navigation settings --- .../client/src/components/app/Layout.svelte | 164 +++++++++++------- 1 file changed, 98 insertions(+), 66 deletions(-) diff --git a/packages/client/src/components/app/Layout.svelte b/packages/client/src/components/app/Layout.svelte index fccdef7dcc..d7517b06b8 100644 --- a/packages/client/src/components/app/Layout.svelte +++ b/packages/client/src/components/app/Layout.svelte @@ -38,6 +38,8 @@ "Extra small": "xs", } + let mobileOpen = false + // Set some layout context. This isn't used in bindings but can be used // determine things about the current app layout. $: mobile = $context.device.mobile @@ -58,7 +60,25 @@ $context.device.width, $context.device.height ) - let mobileOpen = false + + // Scroll navigation into view if selected + $: { + if ( + $builderStore.inBuilder && + $builderStore.selectedComponentId === "navigation" + ) { + const node = document.getElementsByClassName("nav-wrapper")?.[0] + if (node) { + console.log("scroll") + node.style.scrollMargin = "100px" + node.scrollIntoView({ + behavior: "smooth", + block: "start", + inline: "start", + }) + } + } + } const isInternal = url => { return url.startsWith("/") @@ -111,76 +131,85 @@ > {#if typeClass !== "none"}