Parcourir la source

Merge branch 'feature-tianyong' into gym-online

TIANYONG il y a 7 mois
Parent
commit
6e6363b9db

+ 3 - 1
src/constant/instruments.ts

@@ -201,7 +201,9 @@ const instruments: any = {
 	'Brake Drum': '闸鼓',
 	'Tam-tam': '大锣',
 	Cymbal: '镲',
-	Cymbals: '镲'
+	Cymbals: '镲',
+	Whip: '乐鞭',
+	whip: '乐鞭'
 };
 /** 获取分轨名称 */
 export const getInstrumentName = (name = '') => {

+ 2 - 0
src/constant/instrumentsClassfiy.ts

@@ -197,6 +197,8 @@ const instrumentsClassfiy: any = {
 		"Drums set",
 		"High Bongo",
 		"Timbales",
+		"Whip",
+		"whip"
 	],
 };
 

+ 17 - 7
src/state.ts

@@ -1360,7 +1360,7 @@ export const hanldeDirectSelection = (list: any[]) => {
     console.log('选段小节', state.section)
   }, 0);
 };
-let offsetTop = 0;
+let offsetTop = 0, musicScrollTop = 0;
 /**
  * 窗口内滚动到音符的区域
  * @param isScroll 可选: 强制滚动到顶部, 默认: false
@@ -1372,24 +1372,34 @@ 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}`) : document.querySelector(`[data-vf=${domId}]`)?.parentElement;
   const musicAndSelection = document.getElementById(state.scrollContainer)!;
   if (!state.headTopHeight) {
     state.headTopHeight = document.querySelector('.headHeight')?.getBoundingClientRect()?.height || 100;
   }
-  // console.log('滑动',cursorElement.offsetTop,offsetTop, cursorElement, )
-  if (!cursorElement || !musicAndSelection || offsetTop === cursorElement.offsetTop || Math.abs(offsetTop - cursorElement.offsetTop) < 30) return;
+  // console.log('滑动',musicAndSelection?.scrollTop, musicScrollTop)
+  if (!cursorElement || !musicAndSelection) {
+    return
+  }
+  if (Math.abs(musicAndSelection?.scrollTop - musicScrollTop) > 30) {
+    // 手动滑动谱面,重新播放需要滚动到对应位置
+  } else {
+    if (offsetTop === cursorElement.offsetTop || Math.abs(offsetTop - cursorElement.offsetTop) < 30) return;
+  }
   offsetTop = cursorElement.offsetTop;
   if (offsetTop > (state.headTopHeight + 30)) {
+    musicScrollTop = (offsetTop - state.headTopHeight - 30) * state.musicZoom
     musicAndSelection.scrollTo({
       top: (offsetTop - state.headTopHeight - 30) * state.musicZoom,
       behavior: "smooth",
     });
   } else {
+    musicScrollTop = 0
     musicAndSelection.scrollTo({
       top: 0,
       behavior: "smooth",

+ 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.MeasureNumberXML}`
 										]}
 										style={item.staveBox}
 										onClick={() => handleSelection(item)}