Browse Source

Scroll to the selected component inside the app preview

pull/6409/head
Andrew Kingston 4 years ago
parent
commit
2b5b6ae282
  1. 16
      packages/client/src/components/Component.svelte

16
packages/client/src/components/Component.svelte

@ -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 &&

Loading…
Cancel
Save