Pārlūkot izejas kodu

fix: 修复简谱,同一小节因为音符可点击区域高度不一致可能导致的播放时,谱面上下滚动的问题

TIANYONG 11 mēneši atpakaļ
vecāks
revīzija
24c58ab39b
2 mainītis faili ar 6 papildinājumiem un 5 dzēšanām
  1. 1 1
      osmd-extended
  2. 5 4
      src/state.ts

+ 1 - 1
osmd-extended

@@ -1 +1 @@
-Subproject commit 6106f19f06cc5815d2f2069a1370cac1cb228d8e
+Subproject commit f757e1c4b7125efbdf514db6a6835335829d20ec

+ 5 - 4
src/state.ts

@@ -1281,12 +1281,13 @@ export const scrollViewNote = () => {
   const domId = "vf" + noteId;
   const cursorElement: any = document.querySelector(`[data-vf=${domId}]`)?.parentElement;
   const musicAndSelection = document.getElementById(state.scrollContainer)!;
+  const noteCenterOffsetTop = cursorElement ? cursorElement?.offsetTop + (cursorElement?.offsetHeight/2) : 0;
   // console.log('滑动',cursorElement.offsetTop,offsetTop, cursorElement, )
-  if (!cursorElement || !musicAndSelection || offsetTop === cursorElement.offsetTop || Math.abs(offsetTop - cursorElement.offsetTop) < 30) return;
-  offsetTop = cursorElement.offsetTop;
-  if (offsetTop > 50) {
+  if (!cursorElement || !noteCenterOffsetTop || !musicAndSelection || offsetTop === noteCenterOffsetTop || Math.abs(offsetTop - noteCenterOffsetTop) < 30) return;
+  offsetTop = noteCenterOffsetTop;
+  if (offsetTop > 100) {
     musicAndSelection.scrollTo({
-      top: (offsetTop - 50) * state.musicZoom,
+      top: (offsetTop - 100) * state.musicZoom,
       behavior: "smooth",
     });
   } else {