diff --git a/src/simple-flowchart/components/SimpleFlowchart.vue b/src/simple-flowchart/components/SimpleFlowchart.vue index 716dabf..e85066a 100644 --- a/src/simple-flowchart/components/SimpleFlowchart.vue +++ b/src/simple-flowchart/components/SimpleFlowchart.vue @@ -67,6 +67,10 @@ export default { top: 0, left: 0 }, + dragOrigin: { + x: 0, + y: 0 + } }; }, components: { @@ -184,6 +188,11 @@ export default { }, nodeSelected(id, e) { this.action.dragging = id; + + const node = this.scene.nodes.find(node => node.id === id); + this.dragOrigin.x = node.x; + this.dragOrigin.y = node.y; + this.action.selected = id; this.$emit('nodeClick', id); this.mouse.lastX = e.pageX || e.clientX + document.documentElement.scrollLeft @@ -231,7 +240,11 @@ export default { } if (this.action.dragging) { - this.$emit("nodeMoved", this.action.dragging); + const node = this.scene.nodes.find(node => node.id === this.action.dragging); + const moved = (this.dragOrigin.x !== node.x) || (this.dragOrigin.y !== node.y) + if (moved) { + this.$emit("nodeMoved", this.action.dragging); + } this.action.dragging = null; } @@ -251,7 +264,7 @@ export default { moveSelectedNode(dx, dy) { let index = this.scene.nodes.findIndex((item) => { return item.id === this.action.dragging - }) + }); let left = this.scene.nodes[index].x + dx / this.scene.scale; let top = this.scene.nodes[index].y + dy / this.scene.scale; this.$set(this.scene.nodes, index, Object.assign(this.scene.nodes[index], { diff --git a/src/views/Dashboard.vue b/src/views/Dashboard.vue index cbbb2f1..47aaff2 100644 --- a/src/views/Dashboard.vue +++ b/src/views/Dashboard.vue @@ -4,7 +4,7 @@