Removed unnecessary mouse behaviour and added in a fix for dragging an element into its own drag zone.

This commit is contained in:
Dean 2024-11-26 17:31:32 +00:00
parent 1f0de9b9cb
commit 29c780a458
2 changed files with 12 additions and 14 deletions

View File

@ -480,12 +480,6 @@
} }
} }
const onMoveContent = e => {
if (down || !viewPort) {
return
}
}
const isDraggable = e => { const isDraggable = e => {
const draggable = ["draggable-view", ...draggableClasses] const draggable = ["draggable-view", ...draggableClasses]
return draggable.some(cls => e.target.classList.contains(cls)) return draggable.some(cls => e.target.classList.contains(cls))
@ -596,11 +590,7 @@
}} }}
> >
<div class="content-wrap" style={wrapStyles} bind:this={contentWrap}> <div class="content-wrap" style={wrapStyles} bind:this={contentWrap}>
<div <div class="content" bind:this={mainContent}>
class="content"
bind:this={mainContent}
on:mousemove={Utils.domDebounce(onMoveContent)}
>
<slot name="content" /> <slot name="content" />
</div> </div>
</div> </div>

View File

@ -77,6 +77,17 @@ const automationActions = store => ({
* @param {Object} automation the automaton to be mutated * @param {Object} automation the automaton to be mutated
*/ */
moveBlock: async (sourcePath, destPath, automation) => { moveBlock: async (sourcePath, destPath, automation) => {
// The last part of the source node address, containing the id.
const pathSource = sourcePath.at(-1)
// The last part of the destination node address, containing the id.
const pathEnd = destPath.at(-1)
// If they are the same then ignore the drag and drop
if (pathSource.id === pathEnd.id) {
return
}
// Use core delete to remove and return the deleted block // Use core delete to remove and return the deleted block
// from the automation // from the automation
const { deleted, newAutomation } = store.actions.deleteBlock( const { deleted, newAutomation } = store.actions.deleteBlock(
@ -89,9 +100,6 @@ const automationActions = store => ({
const newRefs = {} const newRefs = {}
store.actions.traverse(newRefs, newAutomation) store.actions.traverse(newRefs, newAutomation)
// The last part of the destination node address, containing the id.
const pathEnd = destPath.at(-1)
let finalPath let finalPath
// If dropping in a branch-step dropzone you need to find // If dropping in a branch-step dropzone you need to find
// the updated parent step route then add the branch details again // the updated parent step route then add the branch details again