|
@@ -1,4 +1,4 @@
|
|
|
-import { installGlobalVar, useStage } from "./use-global-vars.ts";
|
|
|
|
|
|
|
+import { installGlobalVar, useCursor, useStage } from "./use-global-vars.ts";
|
|
|
import { useCan, useMode } from "./use-status";
|
|
import { useCan, useMode } from "./use-status";
|
|
|
import { DrawItem, ShapeType } from "../components";
|
|
import { DrawItem, ShapeType } from "../components";
|
|
|
import { nextTick, reactive, Ref, ref, watch, watchEffect } from "vue";
|
|
import { nextTick, reactive, Ref, ref, watch, watchEffect } from "vue";
|
|
@@ -236,6 +236,7 @@ export const useInteractiveDots = ({
|
|
|
const messages = ref<Pos[]>([]);
|
|
const messages = ref<Pos[]>([]);
|
|
|
const stage = useStage();
|
|
const stage = useStage();
|
|
|
const shapesStatus = useMouseShapesStatus();
|
|
const shapesStatus = useMouseShapesStatus();
|
|
|
|
|
+ const cursor = useCursor();
|
|
|
|
|
|
|
|
const init = (dom: HTMLDivElement) => {
|
|
const init = (dom: HTMLDivElement) => {
|
|
|
if (!can.dragMode) return () => {};
|
|
if (!can.dragMode) return () => {};
|
|
@@ -246,6 +247,32 @@ export const useInteractiveDots = ({
|
|
|
const beforePointer = ref(empty);
|
|
const beforePointer = ref(empty);
|
|
|
enter && enter();
|
|
enter && enter();
|
|
|
mode.add(Mode.draging);
|
|
mode.add(Mode.draging);
|
|
|
|
|
+ let popCursor: (() => void) | null = null
|
|
|
|
|
+
|
|
|
|
|
+ const getSelectIds = (ev: MouseEvent) => {
|
|
|
|
|
+ if (preSelectIds?.length && $stage) {
|
|
|
|
|
+ const joinIds: string[] = [];
|
|
|
|
|
+ for (const id of preSelectIds) {
|
|
|
|
|
+ const $shape = $stage.findOne(`#${id}`);
|
|
|
|
|
+ if (!$shape) continue;
|
|
|
|
|
+
|
|
|
|
|
+ const rect = $shape.getClientRect();
|
|
|
|
|
+ let x = ev.offsetX,
|
|
|
|
|
+ y = ev.offsetY;
|
|
|
|
|
+ if (
|
|
|
|
|
+ x > rect.x &&
|
|
|
|
|
+ x < rect.x + rect.width &&
|
|
|
|
|
+ y > rect.y &&
|
|
|
|
|
+ y < rect.y + rect.height
|
|
|
|
|
+ ) {
|
|
|
|
|
+ joinIds.push(id);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (joinIds.length) {
|
|
|
|
|
+ return joinIds;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
const posMove = (position: Pos) => {
|
|
const posMove = (position: Pos) => {
|
|
|
if (!can.dragMode) return;
|
|
if (!can.dragMode) return;
|
|
@@ -263,6 +290,11 @@ export const useInteractiveDots = ({
|
|
|
};
|
|
};
|
|
|
const move = (ev: MouseEvent) => {
|
|
const move = (ev: MouseEvent) => {
|
|
|
posMove(getOffset(ev));
|
|
posMove(getOffset(ev));
|
|
|
|
|
+ popCursor && popCursor()
|
|
|
|
|
+ popCursor = null
|
|
|
|
|
+ if (getSelectIds(ev)?.length) {
|
|
|
|
|
+ popCursor = cursor.push('pointer')
|
|
|
|
|
+ }
|
|
|
};
|
|
};
|
|
|
const preSelectIds = interactiveProps.value?.operate?.preSelectIds;
|
|
const preSelectIds = interactiveProps.value?.operate?.preSelectIds;
|
|
|
|
|
|
|
@@ -277,7 +309,9 @@ export const useInteractiveDots = ({
|
|
|
return mergeFuns(
|
|
return mergeFuns(
|
|
|
() => {
|
|
() => {
|
|
|
mode.del(Mode.draging);
|
|
mode.del(Mode.draging);
|
|
|
- shapesStatus.actives = []
|
|
|
|
|
|
|
+ shapesStatus.actives = [];
|
|
|
|
|
+ popCursor && popCursor()
|
|
|
|
|
+ popCursor = null
|
|
|
},
|
|
},
|
|
|
watch(singleDone, () => {
|
|
watch(singleDone, () => {
|
|
|
if (singleDone.value) {
|
|
if (singleDone.value) {
|
|
@@ -294,28 +328,10 @@ export const useInteractiveDots = ({
|
|
|
clickListener(dom, (_, ev) => {
|
|
clickListener(dom, (_, ev) => {
|
|
|
if (!moveIng || !can.dragMode || eqPoint(prevPoint, pointer.value))
|
|
if (!moveIng || !can.dragMode || eqPoint(prevPoint, pointer.value))
|
|
|
return;
|
|
return;
|
|
|
- if (preSelectIds?.length && $stage) {
|
|
|
|
|
- const joinIds: string[] = [];
|
|
|
|
|
- for (const id of preSelectIds) {
|
|
|
|
|
- const $shape = $stage.findOne(`#${id}`);
|
|
|
|
|
- if (!$shape) continue;
|
|
|
|
|
-
|
|
|
|
|
- const rect = $shape.getClientRect();
|
|
|
|
|
- let x = ev.offsetX,
|
|
|
|
|
- y = ev.offsetY;
|
|
|
|
|
- if (
|
|
|
|
|
- x > rect.x &&
|
|
|
|
|
- x < rect.x + rect.width &&
|
|
|
|
|
- y > rect.y &&
|
|
|
|
|
- y < rect.y + rect.height
|
|
|
|
|
- ) {
|
|
|
|
|
- joinIds.push(id);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- if (joinIds.length) {
|
|
|
|
|
- attachInfos.set(pointer.value, joinIds);
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ const joinIds = getSelectIds(ev);
|
|
|
|
|
+ if (joinIds?.length) {
|
|
|
|
|
+ attachInfos.set(pointer.value, joinIds);
|
|
|
|
|
+ return;
|
|
|
}
|
|
}
|
|
|
singleDone.value = true;
|
|
singleDone.value = true;
|
|
|
}),
|
|
}),
|