|
@@ -1,6 +1,13 @@
|
|
<template>
|
|
<template>
|
|
- <div class="review-mark-pan">
|
|
|
|
- <div class="pan-head"></div>
|
|
|
|
|
|
+ <div ref="reviewMarkPanRef" class="review-mark-pan" :style="areaStyle">
|
|
|
|
+ <div
|
|
|
|
+ class="pan-head"
|
|
|
|
+ v-ele-move-directive.prevent.stop="{
|
|
|
|
+ moveStart: moveAreaStart,
|
|
|
|
+ moveElement: moveArea,
|
|
|
|
+ moveStop: moveAreaStop,
|
|
|
|
+ }"
|
|
|
|
+ ></div>
|
|
<div class="pan-body">
|
|
<div class="pan-body">
|
|
<p>{{ reviewStore.curTask?.examNumber }}</p>
|
|
<p>{{ reviewStore.curTask?.examNumber }}</p>
|
|
<p>{{ reviewStore.curTask?.name }}</p>
|
|
<p>{{ reviewStore.curTask?.name }}</p>
|
|
@@ -11,7 +18,10 @@
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
|
|
+import { ref, computed, reactive, onMounted, onBeforeMount } from "vue";
|
|
import { useReviewStore } from "@/store";
|
|
import { useReviewStore } from "@/store";
|
|
|
|
+import { vEleMoveDirective } from "@/directives/eleMove";
|
|
|
|
+import { local } from "@/utils/tool";
|
|
|
|
|
|
defineOptions({
|
|
defineOptions({
|
|
name: "ReviewMarkPan",
|
|
name: "ReviewMarkPan",
|
|
@@ -24,4 +34,94 @@ const reviewStore = useReviewStore();
|
|
function onMark() {
|
|
function onMark() {
|
|
emit("mark", true);
|
|
emit("mark", true);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+// move
|
|
|
|
+const areaSize = reactive({
|
|
|
|
+ left: 200,
|
|
|
|
+ top: 300,
|
|
|
|
+});
|
|
|
|
+
|
|
|
|
+const areaStyle = computed(() => {
|
|
|
|
+ return { left: `${areaSize.left}px`, top: `${areaSize.top}px` };
|
|
|
|
+});
|
|
|
|
+let areaOriginSize = {
|
|
|
|
+ left: 40,
|
|
|
|
+ top: 0,
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+interface MovePos {
|
|
|
|
+ left: number;
|
|
|
|
+ top: number;
|
|
|
|
+}
|
|
|
|
+interface MarkPanCacheData {
|
|
|
|
+ left: number;
|
|
|
|
+ top: number;
|
|
|
|
+ limitWidth: number;
|
|
|
|
+ limitHeight: number;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+const reviewMarkPanRef = ref();
|
|
|
|
+let limitWidth = 0;
|
|
|
|
+let limitHeight = 0;
|
|
|
|
+let panWidth = 0;
|
|
|
|
+let panHeight = 0;
|
|
|
|
+
|
|
|
|
+function moveAreaStart() {
|
|
|
|
+ areaOriginSize = { ...areaSize };
|
|
|
|
+ updateStaticSize();
|
|
|
|
+}
|
|
|
|
+function moveArea(pos: MovePos) {
|
|
|
|
+ const areaTop = pos.top + areaOriginSize.top;
|
|
|
|
+ areaSize.top = Math.min(areaTop, limitHeight - panHeight);
|
|
|
|
+ areaSize.top = Math.max(0, areaSize.top);
|
|
|
|
+ const areaLeft = pos.left + areaOriginSize.left;
|
|
|
|
+ areaSize.left = Math.min(areaLeft, limitWidth - panWidth);
|
|
|
|
+ areaSize.left = Math.max(0, areaSize.left);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+function moveAreaStop(pos: MovePos) {
|
|
|
|
+ moveArea(pos);
|
|
|
|
+
|
|
|
|
+ local.set("mark-pan", {
|
|
|
|
+ ...areaSize,
|
|
|
|
+ limitHeight,
|
|
|
|
+ limitWidth,
|
|
|
|
+ });
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+function updateStaticSize() {
|
|
|
|
+ const panDom = reviewMarkPanRef.value as HTMLDivElement;
|
|
|
|
+ panWidth = panDom.clientWidth;
|
|
|
|
+ panHeight = panDom.clientHeight;
|
|
|
|
+ const parentDom = panDom.parentElement as HTMLDivElement;
|
|
|
|
+ limitWidth = parentDom.clientWidth;
|
|
|
|
+ limitHeight = parentDom.clientHeight;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+function initAreaSize() {
|
|
|
|
+ const cacheSize: MarkPanCacheData | null = local.get("mark-pan");
|
|
|
|
+ updateStaticSize();
|
|
|
|
+
|
|
|
|
+ if (!cacheSize) {
|
|
|
|
+ areaSize.left = (limitWidth - panWidth) / 2;
|
|
|
|
+ areaSize.top = (limitHeight - panHeight) / 2;
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ const rate = limitWidth / cacheSize.limitWidth;
|
|
|
|
+ const areaLeft = (limitWidth * cacheSize.left) / cacheSize.limitWidth;
|
|
|
|
+ areaSize.left = Math.min(areaLeft, limitWidth - panWidth);
|
|
|
|
+ const areaTop = (limitHeight * cacheSize.top) / cacheSize.limitHeight;
|
|
|
|
+ areaSize.top = Math.min(areaTop, limitHeight - panHeight);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+onMounted(() => {
|
|
|
|
+ initAreaSize();
|
|
|
|
+
|
|
|
|
+ window.addEventListener("resize", initAreaSize);
|
|
|
|
+});
|
|
|
|
+
|
|
|
|
+onBeforeMount(() => {
|
|
|
|
+ window.removeEventListener("resize", initAreaSize);
|
|
|
|
+});
|
|
</script>
|
|
</script>
|