|
@@ -5,7 +5,9 @@
|
|
<circle
|
|
<circle
|
|
v-for="i in pointsAttr"
|
|
v-for="i in pointsAttr"
|
|
v-bind="i"
|
|
v-bind="i"
|
|
- :key="i.id"
|
|
|
|
|
|
+ :key="i.pos"
|
|
|
|
+ @mouseenter="pointMouseEnter(i)"
|
|
|
|
+ @mouseleave="pointMouseLeave(i)"
|
|
@mousedown="($event) => startLine($event, i)"
|
|
@mousedown="($event) => startLine($event, i)"
|
|
></circle>
|
|
></circle>
|
|
</g>
|
|
</g>
|
|
@@ -21,12 +23,25 @@ import {
|
|
computed,
|
|
computed,
|
|
} from "vue";
|
|
} from "vue";
|
|
import { sticky } from "../utils/index";
|
|
import { sticky } from "../utils/index";
|
|
-const props = defineProps(["pos", "size", "mousePos", "id", "draggingId"]);
|
|
|
|
|
|
+const props = defineProps([
|
|
|
|
+ "pos",
|
|
|
|
+ "size",
|
|
|
|
+ "mousePos",
|
|
|
|
+ "startPoint",
|
|
|
|
+ "id",
|
|
|
|
+ "draggingId",
|
|
|
|
+]);
|
|
const boxPos = ref(props.pos);
|
|
const boxPos = ref(props.pos);
|
|
const boxSize = ref(props.size);
|
|
const boxSize = ref(props.size);
|
|
const innerPos = ref({ x: 0, y: 0 });
|
|
const innerPos = ref({ x: 0, y: 0 });
|
|
const isDraging = computed(() => props.id === props.draggingId);
|
|
const isDraging = computed(() => props.id === props.draggingId);
|
|
-const emits = defineEmits(["startDrag", "startLine", "updatePos"]);
|
|
|
|
|
|
+const emits = defineEmits([
|
|
|
|
+ "startDrag",
|
|
|
|
+ "startLine",
|
|
|
|
+ "updatePos",
|
|
|
|
+ "endLine",
|
|
|
|
+ "cancelEndLine",
|
|
|
|
+]);
|
|
|
|
|
|
const attr = computed(() => {
|
|
const attr = computed(() => {
|
|
return {
|
|
return {
|
|
@@ -56,7 +71,7 @@ const outlineRectAttr = computed(() => {
|
|
|
|
|
|
const pointsAttr = computed(() => [
|
|
const pointsAttr = computed(() => [
|
|
{
|
|
{
|
|
- id: `${props.id}-top`,
|
|
|
|
|
|
+ pos: `top`,
|
|
cx: boxPos.value.x + boxSize.value.width / 2,
|
|
cx: boxPos.value.x + boxSize.value.width / 2,
|
|
cy: boxPos.value.y,
|
|
cy: boxPos.value.y,
|
|
r: 4,
|
|
r: 4,
|
|
@@ -64,7 +79,7 @@ const pointsAttr = computed(() => [
|
|
fill: "rgba(255,255,255,1)",
|
|
fill: "rgba(255,255,255,1)",
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- id: `${props.id}-right`,
|
|
|
|
|
|
+ pos: `right`,
|
|
cx: boxPos.value.x + boxSize.value.width,
|
|
cx: boxPos.value.x + boxSize.value.width,
|
|
cy: boxPos.value.y + boxSize.value.height / 2,
|
|
cy: boxPos.value.y + boxSize.value.height / 2,
|
|
r: 4,
|
|
r: 4,
|
|
@@ -72,7 +87,7 @@ const pointsAttr = computed(() => [
|
|
fill: "rgba(255,255,255,1)",
|
|
fill: "rgba(255,255,255,1)",
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- id: `${props.id}-bottom`,
|
|
|
|
|
|
+ pos: `bottom`,
|
|
cx: boxPos.value.x + boxSize.value.width / 2,
|
|
cx: boxPos.value.x + boxSize.value.width / 2,
|
|
cy: boxPos.value.y + boxSize.value.height,
|
|
cy: boxPos.value.y + boxSize.value.height,
|
|
r: 4,
|
|
r: 4,
|
|
@@ -80,7 +95,7 @@ const pointsAttr = computed(() => [
|
|
fill: "rgba(255,255,255,1)",
|
|
fill: "rgba(255,255,255,1)",
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- id: `${props.id}-left`,
|
|
|
|
|
|
+ pos: `left`,
|
|
cx: boxPos.value.x,
|
|
cx: boxPos.value.x,
|
|
cy: boxPos.value.y + boxSize.value.height / 2,
|
|
cy: boxPos.value.y + boxSize.value.height / 2,
|
|
r: 4,
|
|
r: 4,
|
|
@@ -108,6 +123,18 @@ function startLine(e, point) {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+function pointMouseEnter(p) {
|
|
|
|
+ if (props.startPoint?.itemId !== props.id) {
|
|
|
|
+ console.log(props.startPoint);
|
|
|
|
+ emits("endLine", {
|
|
|
|
+ point: p,
|
|
|
|
+ id: props.id,
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+function pointMouseLeave() {}
|
|
|
|
+
|
|
function setPos(pos) {
|
|
function setPos(pos) {
|
|
boxPos.value = {
|
|
boxPos.value = {
|
|
x: sticky(pos.x - innerPos.value.x),
|
|
x: sticky(pos.x - innerPos.value.x),
|