Fixed nodes always being draggable
This commit is contained in:
parent
0e139785a5
commit
0dc1af27b5
2 changed files with 10 additions and 3 deletions
|
@ -149,8 +149,10 @@ export default defineComponent({
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
|
||||||
const zoom = (this.getZoomLevel as () => number)();
|
const zoom = (this.getZoomLevel as () => number)();
|
||||||
this.dragged.x += (e.clientX - this.lastMousePosition.x) / zoom;
|
this.dragged = {
|
||||||
this.dragged.y += (e.clientY - this.lastMousePosition.y) / zoom;
|
x: this.dragged.x + (e.clientX - this.lastMousePosition.x) / zoom,
|
||||||
|
y: this.dragged.y + (e.clientY - this.lastMousePosition.y) / zoom
|
||||||
|
}
|
||||||
this.lastMousePosition = {
|
this.lastMousePosition = {
|
||||||
x: e.clientX,
|
x: e.clientX,
|
||||||
y: e.clientY
|
y: e.clientY
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
:transform="`translate(${position.x},${position.y})`"
|
:transform="`translate(${position.x},${position.y})`"
|
||||||
@mouseenter="mouseEnter"
|
@mouseenter="mouseEnter"
|
||||||
@mouseleave="mouseLeave"
|
@mouseleave="mouseLeave"
|
||||||
@mousedown="e => $emit('startDragging', e, node.id)"
|
@mousedown="mouseDown"
|
||||||
>
|
>
|
||||||
<g v-if="shape === Shape.Circle">
|
<g v-if="shape === Shape.Circle">
|
||||||
<circle
|
<circle
|
||||||
|
@ -197,6 +197,11 @@ export default defineComponent({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
mouseDown(e: MouseEvent) {
|
||||||
|
if (this.draggable) {
|
||||||
|
this.$emit('startDragging', e, this.node.id);
|
||||||
|
}
|
||||||
|
},
|
||||||
mouseEnter() {
|
mouseEnter() {
|
||||||
this.hovering = true;
|
this.hovering = true;
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue