Skip to content

Commit df90aae

Browse files
committed
Accept arbitrary query selector to find the anchor elements
1 parent 963b543 commit df90aae

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

components/FancyArrow.vue

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ import { useElementPosition, type SnapPosition } from "./use-element-position";
44
import { useRoughArrow } from "./use-rough-arrow";
55
66
const props = defineProps<{
7-
id1?: string;
8-
id2?: string;
7+
q1?: string;
8+
q2?: string;
9+
id1?: string; // Deprecated
10+
id2?: string; // Deprecated
911
pos1?: SnapPosition;
1012
pos2?: SnapPosition;
1113
x1?: number | string;
@@ -29,21 +31,22 @@ const slideContainer = computed(() => {
2931
3032
const svgContainer = ref<SVGSVGElement>();
3133
32-
const point1 = props.id1
33-
? useElementPosition(
34-
slideContainer,
35-
svgContainer,
36-
`#${props.id1}`,
37-
props.pos1,
38-
)
34+
const query1 = computed(() => {
35+
if (props.q1) return props.q1;
36+
if (props.id1) return `#${props.id1}`;
37+
return undefined;
38+
});
39+
const query2 = computed(() => {
40+
if (props.q2) return props.q2;
41+
if (props.id2) return `#${props.id2}`;
42+
return undefined;
43+
});
44+
45+
const point1 = query1.value
46+
? useElementPosition(slideContainer, svgContainer, query1.value, props.pos1)
3947
: ref({ x: Number(props.x1 ?? 0), y: Number(props.y1 ?? 0) });
40-
const point2 = props.id2
41-
? useElementPosition(
42-
slideContainer,
43-
svgContainer,
44-
`#${props.id2}`,
45-
props.pos2,
46-
)
48+
const point2 = query2.value
49+
? useElementPosition(slideContainer, svgContainer, query2.value, props.pos2)
4750
: ref({ x: Number(props.x2 ?? 0), y: Number(props.y2 ?? 0) });
4851
4952
const { arcSvg, textPosition } = useRoughArrow({

0 commit comments

Comments
 (0)