Browse Source

feat: 给分板Tab键切换题目时,自动滚动到可是区域

chenhao 2 năm trước cách đây
mục cha
commit
271dee14a4

+ 1 - 1
src/features/mark/MarkBoardTrack.vue

@@ -92,7 +92,7 @@
           :key="index"
         >
           <div
-            :id="['bq',question.mainNumber,question.subNumber].join('-')"
+            :id="['kbq',question.mainNumber,question.subNumber].join('-')"
             class="question tw-rounded tw-cursor-pointer tw-relative tw-mb-2"
             :class="isCurrentQuestion(question) && 'current-question'"
             @click="chooseQuestion(question)"

+ 5 - 0
src/features/mark/use/autoChooseFirstQuestion.ts

@@ -3,6 +3,9 @@ import { store } from "@/store/store";
 import { watch } from "vue";
 
 const scrollToQuestionOfBoard = async (question: Question) => {
+  const keyboardNode = document.querySelector(
+    `#kbq-${question.mainNumber}-${question.subNumber}`
+  );
   const node = document.querySelector(
     `#bq-${question.mainNumber}-${question.subNumber}`
   );
@@ -12,6 +15,7 @@ const scrollToQuestionOfBoard = async (question: Question) => {
   if (!questionNode) {
     // 非多媒体阅卷
     node && node.scrollIntoView({ block: "center", behavior: "smooth" });
+    keyboardNode && keyboardNode.scrollIntoView({ block: "center", behavior: "smooth" });
     return;
   }
   // console.log(node);
@@ -34,6 +38,7 @@ const scrollToQuestionOfBoard = async (question: Question) => {
       isMoving = await checkIfEleMoving(questionNode);
     }
     node && node.scrollIntoView({ block: "center", behavior: "smooth" });
+    keyboardNode && keyboardNode.scrollIntoView({ block: "center", behavior: "smooth" });
   }
 };