Explorar o código

fix: 合并休止小节没有音符,页面滚动逻辑修改

TIANYONG hai 4 meses
pai
achega
38a5555ada
Modificáronse 2 ficheiros con 7 adicións e 4 borrados
  1. 5 4
      src/state.ts
  2. 2 0
      src/view/selection/index.tsx

+ 5 - 4
src/state.ts

@@ -1368,11 +1368,12 @@ export const scrollViewNote = (resetTop?: boolean) => {
     return;
   }
   const noteId = state.times[state.activeNoteIndex].id;
-  if (!noteId) {
-    return;
-  }
+  // if (!noteId) {
+  //   return;
+  // }
   const domId = "vf" + noteId;
-  const cursorElement: any = document.querySelector(`[data-vf=${domId}]`)?.parentElement;
+  // 合并休止小节没有音符,取小节的位置,否则取音符指针位置
+  const cursorElement: any = !noteId && state.times[state.activeNoteIndex]?.totalMultipleRestMeasures ? document.querySelector(`.measureIndex_${state.activeMeasureIndex-1}`) : document.querySelector(`[data-vf=${domId}]`)?.parentElement;
   const musicAndSelection = document.getElementById(state.scrollContainer)!;
   if (!state.headTopHeight) {
     state.headTopHeight = document.querySelector('.headHeight')?.getBoundingClientRect()?.height || 100;

+ 2 - 0
src/view/selection/index.tsx

@@ -147,6 +147,7 @@ export default defineComponent({
 							selectData.measureHeight = staveBbox.height
 							let compareVal = staveBbox.height - minMeasureHeigt
 							compareVal = compareVal > 0 ? compareVal : 0
+							selectData.measureHeight = staveBbox.height - compareVal
 							noteItem.staveBox = {
 								left: staveBbox.x - parentLeft + "px",
 								// top: ((item.stave.y || 0) - 5) * state.zoom + "px",
@@ -309,6 +310,7 @@ export default defineComponent({
 											styles.position,
 											// scoreItem ? `scoreItemLeve${scoreItem.leve}` : "", // 去掉评测小节得分的背景色
 											(state.platform === IPlatform.PC && state.zoom > 0.8) ? styles.linePC : '',
+											`measureIndex_${item.index}`
 										]}
 										style={item.staveBox}
 										onClick={() => handleSelection(item)}