Prevent pointer events in components while dragging

This commit is contained in:
Andrew Kingston 2024-08-01 08:52:41 +01:00
parent 391294f7a1
commit 7433b073c5
No known key found for this signature in database
1 changed files with 11 additions and 4 deletions

View File

@ -27,10 +27,8 @@
// Set ephemeral grid styles on the dragged component
$: instance = componentStore.actions.getComponentInstance(id)
$: $instance?.setEphemeralStyles({
...$gridStyles,
...($gridStyles ? { "z-index": 999 } : null),
})
$: componentStyles = getComponentStyles($gridStyles)
$: $instance?.setEphemeralStyles(componentStyles)
// Sugar for a combination of both min and max
const minMax = (value, min, max) => Math.min(max, Math.max(min, value))
@ -41,6 +39,15 @@
return [...component?.children][0]
}
const getComponentStyles = gridStyles => {
let styles = { ...gridStyles }
if (gridStyles) {
styles["z-index"] = 999
styles["pointer-events"] = "none"
}
return styles
}
const processEvent = Utils.throttle((mouseX, mouseY) => {
if (!dragInfo?.grid) {
return