|
@@ -13,19 +13,23 @@
|
|
<script lang="ts" setup>
|
|
<script lang="ts" setup>
|
|
import { Pos } from "@/utils/math.ts";
|
|
import { Pos } from "@/utils/math.ts";
|
|
import { themeColor } from "@/constant";
|
|
import { themeColor } from "@/constant";
|
|
-import { computed, ref, watch } from "vue";
|
|
|
|
|
|
+import { computed, onUnmounted, ref, watch } from "vue";
|
|
import { DC } from "@/deconstruction";
|
|
import { DC } from "@/deconstruction";
|
|
import { Circle } from "konva/lib/shapes/Circle";
|
|
import { Circle } from "konva/lib/shapes/Circle";
|
|
import { useShapeDrag } from "@/core/hook/use-transformer.ts";
|
|
import { useShapeDrag } from "@/core/hook/use-transformer.ts";
|
|
import { getMouseColors } from "@/utils/colors";
|
|
import { getMouseColors } from "@/utils/colors";
|
|
-import { useCustomSnapInfos, useGlobalSnapInfos, useSnap } from "@/core/hook/use-snap";
|
|
|
|
|
|
+import {
|
|
|
|
+ useCustomSnapInfos,
|
|
|
|
+ useGlobalSnapInfos,
|
|
|
|
+ useSnap,
|
|
|
|
+ useSnapResultInfo,
|
|
|
|
+} from "@/core/hook/use-snap";
|
|
import { generateSnapInfos } from "../util";
|
|
import { generateSnapInfos } from "../util";
|
|
import { ComponentSnapInfo } from "..";
|
|
import { ComponentSnapInfo } from "..";
|
|
import { useShapeIsHover } from "@/core/hook/use-mouse-status";
|
|
import { useShapeIsHover } from "@/core/hook/use-mouse-status";
|
|
import { useCursor } from "@/core/hook/use-global-vars";
|
|
import { useCursor } from "@/core/hook/use-global-vars";
|
|
-import { rangMod } from "@/utils/shared";
|
|
|
|
|
|
+import { mergeFuns, rangMod } from "@/utils/shared";
|
|
import { Operate } from "../../html-mount/propertys/index.ts";
|
|
import { Operate } from "../../html-mount/propertys/index.ts";
|
|
-import { collapseItemProps } from "element-plus";
|
|
|
|
import { useViewer } from "@/core/hook/use-viewer.ts";
|
|
import { useViewer } from "@/core/hook/use-viewer.ts";
|
|
|
|
|
|
const props = defineProps<{
|
|
const props = defineProps<{
|
|
@@ -116,14 +120,21 @@ watch(
|
|
);
|
|
);
|
|
const dragIng = ref(false);
|
|
const dragIng = ref(false);
|
|
let init: Pos;
|
|
let init: Pos;
|
|
|
|
+let onUmHooks: (() => void)[] = [];
|
|
|
|
+const resultInfo = useSnapResultInfo();
|
|
watch(offset, (offset, oldOffsert) => {
|
|
watch(offset, (offset, oldOffsert) => {
|
|
snap.clear();
|
|
snap.clear();
|
|
if (!oldOffsert) {
|
|
if (!oldOffsert) {
|
|
init = { ...position.value };
|
|
init = { ...position.value };
|
|
startHandler();
|
|
startHandler();
|
|
- emit("dragstart");
|
|
|
|
- cursor.push("./icons/m_move.png");
|
|
|
|
dragIng.value = true;
|
|
dragIng.value = true;
|
|
|
|
+ onUmHooks.push(() => {
|
|
|
|
+ emit("dragend");
|
|
|
|
+ clearInfos();
|
|
|
|
+ dragIng.value = false;
|
|
|
|
+ viewer.disabled.value = false;
|
|
|
|
+ resultInfo.clear();
|
|
|
|
+ });
|
|
}
|
|
}
|
|
if (offset) {
|
|
if (offset) {
|
|
const point = {
|
|
const point = {
|
|
@@ -133,18 +144,16 @@ watch(offset, (offset, oldOffsert) => {
|
|
const refSnapInfos = props.getSelfSnapInfos
|
|
const refSnapInfos = props.getSelfSnapInfos
|
|
? props.getSelfSnapInfos(point)
|
|
? props.getSelfSnapInfos(point)
|
|
: generateSnapInfos([point], true, true);
|
|
: generateSnapInfos([point], true, true);
|
|
- // console.log(refSnapInfos);
|
|
|
|
const transform = snap.move(refSnapInfos);
|
|
const transform = snap.move(refSnapInfos);
|
|
emit("update:position", transform ? transform.point(point) : point);
|
|
emit("update:position", transform ? transform.point(point) : point);
|
|
} else {
|
|
} else {
|
|
- emit("dragend");
|
|
|
|
- cursor.pop();
|
|
|
|
- clearInfos();
|
|
|
|
- dragIng.value = false;
|
|
|
|
- viewer.disabled.value = false;
|
|
|
|
|
|
+ mergeFuns(onUmHooks)();
|
|
|
|
+ onUmHooks.length = 0;
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+onUnmounted(() => mergeFuns(onUmHooks)());
|
|
|
|
+
|
|
watch(
|
|
watch(
|
|
() => props.disable,
|
|
() => props.disable,
|
|
(disable) => {
|
|
(disable) => {
|