Scroll preview to the top to show navigation whenever editing navigation settings
This commit is contained in:
parent
8ee95c0779
commit
b281e233b3
|
@ -38,6 +38,8 @@
|
||||||
"Extra small": "xs",
|
"Extra small": "xs",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mobileOpen = false
|
||||||
|
|
||||||
// Set some layout context. This isn't used in bindings but can be used
|
// Set some layout context. This isn't used in bindings but can be used
|
||||||
// determine things about the current app layout.
|
// determine things about the current app layout.
|
||||||
$: mobile = $context.device.mobile
|
$: mobile = $context.device.mobile
|
||||||
|
@ -58,7 +60,25 @@
|
||||||
$context.device.width,
|
$context.device.width,
|
||||||
$context.device.height
|
$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 => {
|
const isInternal = url => {
|
||||||
return url.startsWith("/")
|
return url.startsWith("/")
|
||||||
|
@ -110,12 +130,20 @@
|
||||||
class:mobile={!!mobile}
|
class:mobile={!!mobile}
|
||||||
>
|
>
|
||||||
{#if typeClass !== "none"}
|
{#if typeClass !== "none"}
|
||||||
|
<div
|
||||||
|
class="interactive component navigation"
|
||||||
|
data-id="navigation"
|
||||||
|
data-name="Navigation"
|
||||||
|
data-icon="Link"
|
||||||
|
>
|
||||||
<div
|
<div
|
||||||
class="nav-wrapper"
|
class="nav-wrapper"
|
||||||
class:sticky
|
class:sticky
|
||||||
class:hidden={$routeStore.queryParams?.peek}
|
class:hidden={$routeStore.queryParams?.peek}
|
||||||
class:clickable={$builderStore.inBuilder}
|
class:clickable={$builderStore.inBuilder}
|
||||||
on:click={$builderStore.inBuilder ? builderStore.actions.clickNav : null}
|
on:click={$builderStore.inBuilder
|
||||||
|
? builderStore.actions.clickNav
|
||||||
|
: null}
|
||||||
style={navStyle}
|
style={navStyle}
|
||||||
>
|
>
|
||||||
<div class="nav nav--{typeClass} size--{navWidthClass}">
|
<div class="nav nav--{typeClass} size--{navWidthClass}">
|
||||||
|
@ -183,6 +211,7 @@
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<div class="main-wrapper">
|
<div class="main-wrapper">
|
||||||
<div class="main size--{pageWidthClass}">
|
<div class="main size--{pageWidthClass}">
|
||||||
|
@ -193,6 +222,9 @@
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
/* Main components */
|
/* Main components */
|
||||||
|
.component {
|
||||||
|
display: contents;
|
||||||
|
}
|
||||||
.layout {
|
.layout {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
Loading…
Reference in New Issue