1
0
Fork 0
mirror of synced 2024-07-04 14:01:27 +12:00

Scroll to the selected component inside the app preview

This commit is contained in:
Andrew Kingston 2022-05-17 14:10:21 +01:00
parent a2d8f143e9
commit 2b5b6ae282

View file

@ -136,6 +136,9 @@
// Determine and apply settings to the component
$: applySettings(staticSettings, enrichedSettings, conditionalSettings)
// Scroll the selected element into view
$: selected && scrollIntoView()
// Update component context
$: store.set({
id,
@ -374,6 +377,19 @@
}
}
const scrollIntoView = () => {
const node = document.getElementsByClassName(id)?.[0]?.childNodes[0]
if (!node) {
return
}
node.style.scrollMargin = "80px"
node.scrollIntoView({
behavior: "smooth",
block: "start",
inline: "start",
})
}
onMount(() => {
if (
$appStore.isDevApp &&