1
0
Fork 0
mirror of synced 2024-07-08 15:56:23 +12:00

Stop preview jumping when scrolling to components, and improve scrolling behaviour

This commit is contained in:
Andrew Kingston 2023-08-22 18:55:36 +01:00
parent d0414812cf
commit a83e987dcd
2 changed files with 9 additions and 7 deletions

View file

@ -475,7 +475,7 @@
node.style.scrollMargin = "100px"
node.scrollIntoView({
behavior: "smooth",
block: "start",
block: "nearest",
inline: "start",
})
}

View file

@ -73,18 +73,20 @@
)
$: autoCloseSidePanel = !$builderStore.inBuilder && $sidePanelStore.open
// Scroll navigation into view if selected
// Scroll navigation into view if selected.
// Memoize into a primitive to avoid spamming this whenever builder store
// changes.
$: selected =
$builderStore.inBuilder &&
$builderStore.selectedComponentId === "navigation"
$: {
if (
$builderStore.inBuilder &&
$builderStore.selectedComponentId === "navigation"
) {
if (selected) {
const node = document.getElementsByClassName("nav-wrapper")?.[0]
if (node) {
node.style.scrollMargin = "100px"
node.scrollIntoView({
behavior: "smooth",
block: "start",
block: "nearest",
inline: "start",
})
}