Don't reset component padded state for DND until dragging stops, to prevent jankiness due to losing space
This commit is contained in:
parent
a71a553ee6
commit
4e94b6633f
|
@ -16,7 +16,13 @@
|
||||||
propsAreSame,
|
propsAreSame,
|
||||||
getSettingsDefinition,
|
getSettingsDefinition,
|
||||||
} from "utils/componentProps"
|
} from "utils/componentProps"
|
||||||
import { builderStore, devToolsStore, componentStore, appStore } from "stores"
|
import {
|
||||||
|
builderStore,
|
||||||
|
devToolsStore,
|
||||||
|
componentStore,
|
||||||
|
appStore,
|
||||||
|
isDragging,
|
||||||
|
} from "stores"
|
||||||
import { Helpers } from "@budibase/bbui"
|
import { Helpers } from "@budibase/bbui"
|
||||||
import { getActiveConditions, reduceConditionActions } from "utils/conditions"
|
import { getActiveConditions, reduceConditionActions } from "utils/conditions"
|
||||||
import Placeholder from "components/app/Placeholder.svelte"
|
import Placeholder from "components/app/Placeholder.svelte"
|
||||||
|
@ -152,6 +158,12 @@
|
||||||
// Scroll the selected element into view
|
// Scroll the selected element into view
|
||||||
$: selected && scrollIntoView()
|
$: selected && scrollIntoView()
|
||||||
|
|
||||||
|
// When dragging and dropping, pad components to allow dropping between
|
||||||
|
// nested layers. Only reset this when dragging stops.
|
||||||
|
let pad = false
|
||||||
|
$: pad = pad || (interactive && hasChildren && inDndPath)
|
||||||
|
$: $isDragging, (pad = false)
|
||||||
|
|
||||||
// Update component context
|
// Update component context
|
||||||
$: store.set({
|
$: store.set({
|
||||||
id,
|
id,
|
||||||
|
@ -454,11 +466,11 @@
|
||||||
class:draggable
|
class:draggable
|
||||||
class:droppable
|
class:droppable
|
||||||
class:empty
|
class:empty
|
||||||
class:parent={hasChildren}
|
|
||||||
class:interactive
|
class:interactive
|
||||||
class:editing
|
class:editing
|
||||||
|
class:pad
|
||||||
|
class:parent={hasChildren}
|
||||||
class:block={isBlock}
|
class:block={isBlock}
|
||||||
class:explode={interactive && hasChildren && inDndPath}
|
|
||||||
class:placeholder={id === DNDPlaceholderID}
|
class:placeholder={id === DNDPlaceholderID}
|
||||||
data-id={id}
|
data-id={id}
|
||||||
data-name={name}
|
data-name={name}
|
||||||
|
@ -490,9 +502,9 @@
|
||||||
display: contents;
|
display: contents;
|
||||||
}
|
}
|
||||||
.component :global(> *) {
|
.component :global(> *) {
|
||||||
transition: padding 260ms ease, border 260ms ease;
|
transition: padding 260ms ease-in, border 260ms ease-in;
|
||||||
}
|
}
|
||||||
.component.explode :global(> *) {
|
.component.pad :global(> *) {
|
||||||
padding: 12px !important;
|
padding: 12px !important;
|
||||||
gap: 12px !important;
|
gap: 12px !important;
|
||||||
border: 2px dotted var(--spectrum-global-color-gray-400) !important;
|
border: 2px dotted var(--spectrum-global-color-gray-400) !important;
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
import { Utils } from "@budibase/frontend-core"
|
import { Utils } from "@budibase/frontend-core"
|
||||||
import { findComponentById } from "utils/components.js"
|
import { findComponentById } from "utils/components.js"
|
||||||
|
|
||||||
|
const ThrottleRate = 130
|
||||||
|
|
||||||
// Cache some dnd store state as local variables as it massively helps
|
// Cache some dnd store state as local variables as it massively helps
|
||||||
// performance. It lets us avoid calling svelte getters on every DOM action.
|
// performance. It lets us avoid calling svelte getters on every DOM action.
|
||||||
$: source = $dndStore.source
|
$: source = $dndStore.source
|
||||||
|
@ -191,7 +193,7 @@
|
||||||
index: idx,
|
index: idx,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
const throttledProcessEvent = Utils.throttle(processEvent, 130)
|
const throttledProcessEvent = Utils.throttle(processEvent, ThrottleRate)
|
||||||
|
|
||||||
const handleEvent = e => {
|
const handleEvent = e => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|
|
@ -69,7 +69,7 @@ const loadBudibase = async () => {
|
||||||
parent: null,
|
parent: null,
|
||||||
bounds: {
|
bounds: {
|
||||||
height: 64,
|
height: 64,
|
||||||
width: 64,
|
width: 128,
|
||||||
},
|
},
|
||||||
index: null,
|
index: null,
|
||||||
newComponentType: component,
|
newComponentType: component,
|
||||||
|
|
|
@ -53,6 +53,7 @@ const createComponentStore = () => {
|
||||||
mountedComponentCount: Object.keys($store.mountedComponents).length,
|
mountedComponentCount: Object.keys($store.mountedComponents).length,
|
||||||
currentAsset: asset,
|
currentAsset: asset,
|
||||||
dndPath: dndPath?.map(component => component._id),
|
dndPath: dndPath?.map(component => component._id),
|
||||||
|
dndDepth: dndPath?.length || 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue