Only explode components when dragging over them

This commit is contained in:
Andrew Kingston 2022-10-07 08:20:51 +01:00
parent 4322345aca
commit 9df86362b9
2 changed files with 5 additions and 2 deletions

View File

@ -98,8 +98,8 @@
$: selected =
$builderStore.inBuilder && $builderStore.selectedComponentId === id
$: inSelectedPath = $componentStore.selectedComponentPath?.includes(id)
$: isDndParent = $componentStore.dndParent === id
$: inDragPath = inSelectedPath && $builderStore.editMode
$: inDndPath = $componentStore.dndPath?.includes(id)
// Derive definition properties which can all be optional, so need to be
// coerced to booleans
@ -457,7 +457,7 @@
class:interactive
class:editing
class:block={isBlock}
class:explode={interactive && hasChildren && $builderStore.isDragging}
class:explode={interactive && hasChildren && inDndPath}
class:placeholder={id === "placeholder"}
data-id={id}
data-name={name}

View File

@ -39,6 +39,8 @@ const createComponentStore = () => {
// Derive the selected component path
const selectedPath =
findComponentPathById(asset?.props, selectedComponentId) || []
const dndPath =
findComponentPathById(asset?.props, $builderState.dndParent) || []
return {
customComponentManifest: $store.customComponentManifest,
@ -49,6 +51,7 @@ const createComponentStore = () => {
selectedComponentPath: selectedPath?.map(component => component._id),
mountedComponentCount: Object.keys($store.mountedComponents).length,
currentAsset: asset,
dndPath: dndPath?.map(component => component._id),
}
}
)