计分本坐标改成百分比
This commit is contained in:
@@ -40,7 +40,11 @@ const onClick = async (e) => {
|
|||||||
rect.value.width * 0.9,
|
rect.value.width * 0.9,
|
||||||
rect.value.height - rect.value.top
|
rect.value.height - rect.value.top
|
||||||
);
|
);
|
||||||
arrow.value = newArrow;
|
arrow.value = {
|
||||||
|
...newArrow,
|
||||||
|
x: newArrow.x / (rect.value.width * 0.9),
|
||||||
|
y: newArrow.y / (rect.value.width * 0.9),
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
// 确认添加箭矢
|
// 确认添加箭矢
|
||||||
@@ -80,8 +84,14 @@ const onDrag = async (e) => {
|
|||||||
const height = rect.value.height - rect.value.top;
|
const height = rect.value.height - rect.value.top;
|
||||||
|
|
||||||
// 更新坐标
|
// 更新坐标
|
||||||
arrow.value.x = Math.max(0, Math.min(width, arrow.value.x + deltaX));
|
arrow.value.x = Math.max(
|
||||||
arrow.value.y = Math.max(0, Math.min(height, arrow.value.y + deltaY));
|
0,
|
||||||
|
Math.min(width, arrow.value.x * (rect.value.width * 0.9) + deltaX)
|
||||||
|
);
|
||||||
|
arrow.value.y = Math.max(
|
||||||
|
0,
|
||||||
|
Math.min(height, arrow.value.y * (rect.value.width * 0.9) + deltaY)
|
||||||
|
);
|
||||||
arrow.value.ring = calcRing(
|
arrow.value.ring = calcRing(
|
||||||
props.id,
|
props.id,
|
||||||
arrow.value.x,
|
arrow.value.x,
|
||||||
@@ -89,6 +99,8 @@ const onDrag = async (e) => {
|
|||||||
width,
|
width,
|
||||||
height
|
height
|
||||||
);
|
);
|
||||||
|
arrow.value.x = arrow.value.x / (rect.value.width * 0.9);
|
||||||
|
arrow.value.y = arrow.value.y / (rect.value.width * 0.9);
|
||||||
|
|
||||||
// 更新拖拽起始位置
|
// 更新拖拽起始位置
|
||||||
dragStartPos.value = { x: clientX, y: clientY };
|
dragStartPos.value = { x: clientX, y: clientY };
|
||||||
@@ -118,8 +130,8 @@ onMounted(async () => {
|
|||||||
:key="index"
|
:key="index"
|
||||||
class="arrow-point"
|
class="arrow-point"
|
||||||
:style="{
|
:style="{
|
||||||
left: (arrow.x !== undefined ? arrow.x : 0) + 'px',
|
left: (arrow.x !== undefined ? arrow.x : 0) * 100 + '%',
|
||||||
top: (arrow.y !== undefined ? arrow.y : 0) + 'px',
|
top: (arrow.y !== undefined ? arrow.y : 0) * 100 + '%',
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<view v-if="arrow.x !== undefined && arrow.y !== undefined" class="point"
|
<view v-if="arrow.x !== undefined && arrow.y !== undefined" class="point"
|
||||||
@@ -131,8 +143,8 @@ onMounted(async () => {
|
|||||||
v-if="arrow"
|
v-if="arrow"
|
||||||
class="arrow-point"
|
class="arrow-point"
|
||||||
:style="{
|
:style="{
|
||||||
left: arrow.x + 'px',
|
left: arrow.x * 100 + '%',
|
||||||
top: arrow.y + 'px',
|
top: arrow.y * 100 + '%',
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<!-- 箭矢点 -->
|
<!-- 箭矢点 -->
|
||||||
|
|||||||
@@ -498,5 +498,6 @@ const comingSoon = () => {
|
|||||||
.my-data > view:nth-child(2) > view > text:last-child {
|
.my-data > view:nth-child(2) > view > text:last-child {
|
||||||
color: #fff;
|
color: #fff;
|
||||||
line-height: 25px;
|
line-height: 25px;
|
||||||
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user