|
@@ -341,11 +341,33 @@ export const gotoCustomNote = (index: number) => {
|
|
|
state.osmd.cursor.next();
|
|
|
}
|
|
|
};
|
|
|
+const setCursorPosition = (note: any, cursor: any) => {
|
|
|
+ const scrollContainer = document.getElementById("scrollContainer");
|
|
|
+ const box = scrollContainer?.getBoundingClientRect();
|
|
|
+ if (!box) return;
|
|
|
+ if (
|
|
|
+ state.musicRenderType === EnumMusicRenderType.firstTone ||
|
|
|
+ state.musicRenderType === EnumMusicRenderType.fixedTone
|
|
|
+ ) {
|
|
|
+ const noteBox = note?.svgElement.attrs.el
|
|
|
+ ?.querySelector(".vf-numbered-note-head")
|
|
|
+ ?.getBoundingClientRect();
|
|
|
+ if (!noteBox) return;
|
|
|
+ cursor.cursorElement.style.left = noteBox.x - box.x + "px";
|
|
|
+ }
|
|
|
+};
|
|
|
/** 跳转到下一个音符 */
|
|
|
export const gotoNext = (note: any) => {
|
|
|
const num = note.i;
|
|
|
- // console.log('next', state.activeNoteIndex, num)
|
|
|
- if (state.activeNoteIndex === note.i) return;
|
|
|
+
|
|
|
+ if (state.activeNoteIndex === note.i) {
|
|
|
+ try {
|
|
|
+ setCursorPosition(note, state.osmd.cursor);
|
|
|
+ } catch (error) {
|
|
|
+ console.log(error);
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
const osmd = state.osmd;
|
|
|
let prev = state.activeNoteIndex;
|
|
|
state.activeNoteIndex = num;
|
|
@@ -361,6 +383,11 @@ export const gotoNext = (note: any) => {
|
|
|
} else {
|
|
|
gotoCustomNote(num);
|
|
|
}
|
|
|
+ try {
|
|
|
+ setCursorPosition(note, state.osmd.cursor);
|
|
|
+ } catch (error) {
|
|
|
+ console.log(error);
|
|
|
+ }
|
|
|
|
|
|
scrollViewNote();
|
|
|
};
|