|
@@ -620,7 +620,8 @@ export const skipNotePlay = async (itemIndex: number, isStart = false) => {
|
|
|
}
|
|
|
if (item) {
|
|
|
setAudioCurrentTime(itemTime, itemIndex);
|
|
|
- gotoNext(item);
|
|
|
+ // 一行谱,点击音符,或者播放完成,需要跳转音符位置
|
|
|
+ gotoNext(item, true);
|
|
|
metronomeData.metro?.sound(itemTime);
|
|
|
if (state.isAppPlay) {
|
|
|
await api_cloudSetCurrentTime({
|
|
@@ -753,8 +754,11 @@ const setCursorPosition = (note: any, cursor: any) => {
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
-/** 跳转到下一个音符 */
|
|
|
-export const gotoNext = (note: any) => {
|
|
|
+/**
|
|
|
+ * 跳转到下一个音符
|
|
|
+ * 一行谱,点击音符,或者播放完成,需要跳转音符位置,增加参数skipNote
|
|
|
+ **/
|
|
|
+export const gotoNext = (note: any, skipNote?: boolean) => {
|
|
|
// console.log(33333333333,state.activeNoteIndex,note.i)
|
|
|
const num = note.i;
|
|
|
|
|
@@ -766,7 +770,6 @@ export const gotoNext = (note: any) => {
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
const osmd = state.osmd;
|
|
|
let prev = state.activeNoteIndex;
|
|
|
state.activeNoteIndex = num;
|
|
@@ -789,7 +792,7 @@ export const gotoNext = (note: any) => {
|
|
|
}
|
|
|
// 一行谱,需要滚动小节
|
|
|
if (state.isSingleLine) {
|
|
|
- moveSvgDom();
|
|
|
+ moveSvgDom(skipNote);
|
|
|
}
|
|
|
scrollViewNote();
|
|
|
};
|
|
@@ -1334,7 +1337,7 @@ export const calculateDistance = () => {
|
|
|
}
|
|
|
|
|
|
/** 跳动svgdom */
|
|
|
-export const moveSvgDom = () => {
|
|
|
+export const moveSvgDom = (skipNote?: boolean) => {
|
|
|
// const cursorLeft = state.cursorDom?.getBoundingClientRect()?.left || 0;
|
|
|
// const leftValue = parseFloat(state.cursorDom.style.left) - 47 - 20;
|
|
|
// console.log(cursorLeft,leftValue,'光标位置')
|
|
@@ -1358,11 +1361,13 @@ export const moveSvgDom = () => {
|
|
|
* 计算需要移动的距离
|
|
|
* 当前选中的音符和第一个音符之间的间距
|
|
|
*/
|
|
|
- const distance = state.times[state.activeNoteIndex].bbox?.x - state.times[0].bbox?.x + state.times[state.activeNoteIndex].bbox?.width / 2 - state.times[0].bbox?.width / 2;
|
|
|
- state.osdmScrollDom.scrollTo({
|
|
|
- left: distance,
|
|
|
- behavior: "smooth",
|
|
|
- });
|
|
|
+ if (skipNote) {
|
|
|
+ const distance = state.times[state.activeNoteIndex].bbox?.x - state.times[0].bbox?.x + state.times[state.activeNoteIndex].bbox?.width / 2 - state.times[0].bbox?.width / 2;
|
|
|
+ state.osdmScrollDom.scrollTo({
|
|
|
+ left: distance,
|
|
|
+ behavior: "smooth",
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/** 平滑移动svgdom */
|