Stop preview jumping when scrolling to components, and improve scrolling behaviour
This commit is contained in:
parent
d0414812cf
commit
a83e987dcd
|
@ -475,7 +475,7 @@
|
||||||
node.style.scrollMargin = "100px"
|
node.style.scrollMargin = "100px"
|
||||||
node.scrollIntoView({
|
node.scrollIntoView({
|
||||||
behavior: "smooth",
|
behavior: "smooth",
|
||||||
block: "start",
|
block: "nearest",
|
||||||
inline: "start",
|
inline: "start",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,18 +73,20 @@
|
||||||
)
|
)
|
||||||
$: autoCloseSidePanel = !$builderStore.inBuilder && $sidePanelStore.open
|
$: 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 (
|
if (selected) {
|
||||||
$builderStore.inBuilder &&
|
|
||||||
$builderStore.selectedComponentId === "navigation"
|
|
||||||
) {
|
|
||||||
const node = document.getElementsByClassName("nav-wrapper")?.[0]
|
const node = document.getElementsByClassName("nav-wrapper")?.[0]
|
||||||
if (node) {
|
if (node) {
|
||||||
node.style.scrollMargin = "100px"
|
node.style.scrollMargin = "100px"
|
||||||
node.scrollIntoView({
|
node.scrollIntoView({
|
||||||
behavior: "smooth",
|
behavior: "smooth",
|
||||||
block: "start",
|
block: "nearest",
|
||||||
inline: "start",
|
inline: "start",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue