1
0
Fork 0
mirror of synced 2024-06-25 17:40:38 +12:00

Don't reset component padded state for DND until dragging stops, to prevent jankiness due to losing space

This commit is contained in:
Andrew Kingston 2022-10-14 15:45:02 +01:00
parent d997afffc0
commit 23eb09ab6a
4 changed files with 22 additions and 7 deletions

View file

@ -16,7 +16,13 @@
propsAreSame,
getSettingsDefinition,
} from "utils/componentProps"
import { builderStore, devToolsStore, componentStore, appStore } from "stores"
import {
builderStore,
devToolsStore,
componentStore,
appStore,
isDragging,
} from "stores"
import { Helpers } from "@budibase/bbui"
import { getActiveConditions, reduceConditionActions } from "utils/conditions"
import Placeholder from "components/app/Placeholder.svelte"
@ -152,6 +158,12 @@
// Scroll the selected element into view
$: 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
$: store.set({
id,
@ -454,11 +466,11 @@
class:draggable
class:droppable
class:empty
class:parent={hasChildren}
class:interactive
class:editing
class:pad
class:parent={hasChildren}
class:block={isBlock}
class:explode={interactive && hasChildren && inDndPath}
class:placeholder={id === DNDPlaceholderID}
data-id={id}
data-name={name}
@ -490,9 +502,9 @@
display: contents;
}
.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;
gap: 12px !important;
border: 2px dotted var(--spectrum-global-color-gray-400) !important;

View file

@ -13,6 +13,8 @@
import { Utils } from "@budibase/frontend-core"
import { findComponentById } from "utils/components.js"
const ThrottleRate = 130
// Cache some dnd store state as local variables as it massively helps
// performance. It lets us avoid calling svelte getters on every DOM action.
$: source = $dndStore.source
@ -191,7 +193,7 @@
index: idx,
})
}
const throttledProcessEvent = Utils.throttle(processEvent, 130)
const throttledProcessEvent = Utils.throttle(processEvent, ThrottleRate)
const handleEvent = e => {
e.preventDefault()

View file

@ -69,7 +69,7 @@ const loadBudibase = async () => {
parent: null,
bounds: {
height: 64,
width: 64,
width: 128,
},
index: null,
newComponentType: component,

View file

@ -53,6 +53,7 @@ const createComponentStore = () => {
mountedComponentCount: Object.keys($store.mountedComponents).length,
currentAsset: asset,
dndPath: dndPath?.map(component => component._id),
dndDepth: dndPath?.length || 0,
}
}
)