|
@@ -26,29 +26,50 @@ import CommonMarkBody from "./CommonMarkBody.vue";
|
|
|
// import MarkBody from "@/features/student/studentInspect/MarkBody.vue";
|
|
|
|
|
|
defineEmits(["error", "allZeroSubmit"]);
|
|
|
-
|
|
|
+const isOffsetLessThan1Px = (a: number, b: number, canEqual?: boolean) => {
|
|
|
+ console.log("a - b", a - b);
|
|
|
+ return canEqual ? a - b > -1 && a - b <= 0 : a - b > -1 && a - b < 0;
|
|
|
+};
|
|
|
const makeScoreTrack = (
|
|
|
event: MouseEvent,
|
|
|
item: SliceImage,
|
|
|
maxSliceWidth: number,
|
|
|
theFinalHeight: number
|
|
|
) => {
|
|
|
- // console.log(item);
|
|
|
+ console.log("item", item);
|
|
|
if (!store.currentQuestion || typeof store.currentScore === "undefined")
|
|
|
return;
|
|
|
const target = event.target as HTMLImageElement;
|
|
|
+ let intOffsetX = Math.round(
|
|
|
+ event.offsetX * (target.naturalWidth / target.width) + item.dx
|
|
|
+ );
|
|
|
+ let intOffsetY = Math.round(
|
|
|
+ event.offsetY * (target.naturalHeight / target.height) + item.dy
|
|
|
+ );
|
|
|
+ console.log(
|
|
|
+ "xxx",
|
|
|
+ event.offsetX * (target.naturalWidth / target.width) + item.dx
|
|
|
+ );
|
|
|
+ console.log(
|
|
|
+ "yyy",
|
|
|
+ event.offsetY * (target.naturalHeight / target.height) + item.dy
|
|
|
+ );
|
|
|
const track: Track = {
|
|
|
mainNumber: store.currentQuestion?.mainNumber,
|
|
|
subNumber: store.currentQuestion?.subNumber,
|
|
|
score: store.currentScore,
|
|
|
unanswered: Object.is(store.currentScore, -0),
|
|
|
offsetIndex: item.indexInSliceUrls,
|
|
|
- offsetX: Math.round(
|
|
|
- event.offsetX * (target.naturalWidth / target.width) + item.dx
|
|
|
- ),
|
|
|
- offsetY: Math.round(
|
|
|
- event.offsetY * (target.naturalHeight / target.height) + item.dy
|
|
|
- ),
|
|
|
+ offsetX: isOffsetLessThan1Px(intOffsetX, item.dx)
|
|
|
+ ? Math.ceil(item.dx)
|
|
|
+ : isOffsetLessThan1Px(item.sliceImageWidth, intOffsetX - item.dx)
|
|
|
+ ? intOffsetX - 1
|
|
|
+ : intOffsetX,
|
|
|
+ offsetY: isOffsetLessThan1Px(intOffsetY, item.dy)
|
|
|
+ ? Math.ceil(item.dy)
|
|
|
+ : isOffsetLessThan1Px(item.sliceImageHeight, intOffsetY - item.dy, true)
|
|
|
+ ? intOffsetY - 1
|
|
|
+ : intOffsetY,
|
|
|
positionX: -1,
|
|
|
positionY: -1,
|
|
|
number: -1,
|