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