liushengqiang 1 rok pred
rodič
commit
f64351ba67
1 zmenil súbory, kde vykonal 20 pridanie a 1 odobranie
  1. 20 1
      src/state.ts

+ 20 - 1
src/state.ts

@@ -347,7 +347,26 @@ const setCursorPosition = (note: any, cursor: any) => {
 		state.musicRenderType === EnumMusicRenderType.fixedTone
 	) {
 		nextTick(() => {
-			const bbox = note.bbox;
+			let bbox = note.bbox;
+			if (!bbox) {
+				const musicContainer = document.getElementById("musicAndSelection")?.getBoundingClientRect() || {
+					x: 0,
+					y: 0,
+				};
+				const parentLeft = musicContainer.x || 0;
+				const noteEle = document.querySelector(`#vf-${note.svgElement?.attrs?.id}`);
+				if (noteEle) {
+					const noteHead = noteEle.querySelector(".vf-numbered-note-head");
+					const noteHeadBbox = noteHead?.getBoundingClientRect?.();
+					if (noteHeadBbox) {
+						note.bbox = {
+							left: noteHeadBbox.x - parentLeft - noteHeadBbox.width / 4,
+							width: noteHeadBbox.width * 1.5,
+						};
+						bbox = note.bbox;
+					}
+				}
+			}
 			if (!bbox) return;
 			const baseW = state.platform === IPlatform.PC ? 29 : 18;
 			const width = (bbox.width - baseW) / 3;