Browse Source

feat: 缩小滑音音符的点击区域

TIANYONG 2 months ago
parent
commit
fd1f9a26df
3 changed files with 11 additions and 4 deletions
  1. 1 1
      osmd-extended
  2. 1 1
      src/view/fingering/index.tsx
  3. 9 2
      src/view/selection/index.tsx

+ 1 - 1
osmd-extended

@@ -1 +1 @@
-Subproject commit 6b139a79b2825dd9e4621336e29f5db52c771092
+Subproject commit 1b7f34674ecc1195c5c03e0af63f5983b424aab3

+ 1 - 1
src/view/fingering/index.tsx

@@ -51,7 +51,7 @@ export default defineComponent({
       doubeClick
     })
     return () => {
-      // console.log("音符指法音高", realKey.value);
+      // console.log("音符指法音高", "音符key值", realKey.value);
       const relationship = fingerData.subject?.relationship?.[realKey.value] || [];
       const rs: number[] = Array.isArray(relationship[1]) ? relationship[fingerData.relationshipIndex] : relationship;
       const canTizhi = Array.isArray(relationship[1]);

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

@@ -79,11 +79,18 @@ const calcNoteData = () => {
 						}
 						
 					} else {
+						// 判断是否是滑音,滑音的宽度很大,会覆盖掉前面的音符区域,导致无法点击选中前一个音符,需要缩小滑音的点击区域
+						let vibratoReduceX = 0;
+						if (noteEle?.querySelector('.vf-vibrato')) {
+							vibratoReduceX = 50;
+						} else {
+							vibratoReduceX = 0;
+						}
 						const needTransY = -(staveBbox.height - customBgBox.height) / 2 + "px";
 						noteItem.bbox = {
-							left: noteBbox.x - parentLeft - noteBbox.width / 4 + "px",
+							left: noteBbox.x - parentLeft - noteBbox.width / 4 + vibratoReduceX + "px",
 							top: customBgBox.y ? customBgBox.y - parentTop + "px" : staveBbox.y - parentTop + "px",
-							width: noteBbox.width * 1.5 + "px",
+							width: noteBbox.width * 1.5 - vibratoReduceX + "px",
 							height: staveBbox.height + "px",
 							x: item.bbox?.x,
 							y: item.bbox?.y,