Improve comments and namimg conventions
This commit is contained in:
parent
c6ddbb6d04
commit
702d1ad406
|
@ -25,7 +25,9 @@
|
||||||
// Local flag for whether we are awaiting an async drop event
|
// Local flag for whether we are awaiting an async drop event
|
||||||
let dropping = false
|
let dropping = false
|
||||||
|
|
||||||
const insideGrid = e => {
|
// Util to check if a DND event originates from a grid (or inside a grid).
|
||||||
|
// This is important as we do not handle grid DND in this handler.
|
||||||
|
const isGridEvent = e => {
|
||||||
return e.target
|
return e.target
|
||||||
?.closest?.(".component")
|
?.closest?.(".component")
|
||||||
?.parentNode?.closest?.(".component")
|
?.parentNode?.closest?.(".component")
|
||||||
|
@ -69,7 +71,7 @@
|
||||||
|
|
||||||
// Callback when initially starting a drag on a draggable component
|
// Callback when initially starting a drag on a draggable component
|
||||||
const onDragStart = e => {
|
const onDragStart = e => {
|
||||||
if (insideGrid(e)) {
|
if (isGridEvent(e)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const component = e.target.closest(".component")
|
const component = e.target.closest(".component")
|
||||||
|
|
|
@ -17,7 +17,9 @@
|
||||||
...(gridStyles ? { "z-index": 999 } : null),
|
...(gridStyles ? { "z-index": 999 } : null),
|
||||||
})
|
})
|
||||||
|
|
||||||
const isChildOfGrid = e => {
|
// Util to check if a DND event originates from a grid (or inside a grid).
|
||||||
|
// This is important as we do not handle grid DND in this handler.
|
||||||
|
const isGridEvent = e => {
|
||||||
return (
|
return (
|
||||||
e.target
|
e.target
|
||||||
.closest?.(".component")
|
.closest?.(".component")
|
||||||
|
@ -113,7 +115,7 @@
|
||||||
|
|
||||||
// Callback when initially starting a drag on a draggable component
|
// Callback when initially starting a drag on a draggable component
|
||||||
const onDragStart = e => {
|
const onDragStart = e => {
|
||||||
if (!isChildOfGrid(e)) {
|
if (!isGridEvent(e)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue