|
@@ -1628,12 +1628,15 @@ export const moveSvgDom = (skipNote?: boolean) => {
|
|
* 当前选中的音符和第一个音符之间的间距
|
|
* 当前选中的音符和第一个音符之间的间距
|
|
*/
|
|
*/
|
|
if (skipNote) {
|
|
if (skipNote) {
|
|
|
|
+ // 点击 清空translateXNum
|
|
|
|
+ smoothAnimationState.translateXNum = 0
|
|
|
|
+ moveTranslateXNum(0)
|
|
|
|
+ // 移动小鸟的位置
|
|
|
|
+ moveSmoothAnimation(0, state.activeNoteIndex, false)
|
|
|
|
+ // 移动谱面当当前音符的位置
|
|
const noteWidth = state.times[state.activeNoteIndex].bbox?.originWidth || state.times[state.activeNoteIndex].bbox?.width;
|
|
const noteWidth = state.times[state.activeNoteIndex].bbox?.originWidth || state.times[state.activeNoteIndex].bbox?.width;
|
|
const firstNoteWidth = state.times[0].bbox?.originWidth || state.times[0].bbox?.width;
|
|
const firstNoteWidth = state.times[0].bbox?.originWidth || state.times[0].bbox?.width;
|
|
const distance = state.times[state.activeNoteIndex].bbox?.x - state.times[0].bbox?.x + noteWidth / 2 - firstNoteWidth / 2;
|
|
const distance = state.times[state.activeNoteIndex].bbox?.x - state.times[0].bbox?.x + noteWidth / 2 - firstNoteWidth / 2;
|
|
- // 点击 清空translateXNum
|
|
|
|
- smoothAnimationState.translateXNum = 0
|
|
|
|
- moveSmoothAnimation(0, state.activeNoteIndex)
|
|
|
|
smoothAnimationState.osdmScrollDom!.scrollTo({
|
|
smoothAnimationState.osdmScrollDom!.scrollTo({
|
|
left: distance,
|
|
left: distance,
|
|
behavior: "smooth",
|
|
behavior: "smooth",
|
|
@@ -1650,9 +1653,12 @@ watch(
|
|
// 当在播放中暂停 执行这个方法
|
|
// 当在播放中暂停 执行这个方法
|
|
if (!state.playEnd && state.playState === "paused") {
|
|
if (!state.playEnd && state.playState === "paused") {
|
|
moveTranslateXNum(0)
|
|
moveTranslateXNum(0)
|
|
- const scrollLeft = smoothAnimationState.osdmScrollDom!.scrollLeft
|
|
|
|
- smoothAnimationState.osdmScrollDom!.scrollLeft = scrollLeft + smoothAnimationState.translateXNum
|
|
|
|
- smoothAnimationState.translateXNum = 0
|
|
|
|
|
|
+ // 因为safari浏览器scrollWidth的值一直变化,scrollLeft + smoothAnimationState.translateXNum 为最大宽度的时候,实际上scrollLeft滚不到最大宽度,所以在下一帧处理滚动,能滚动到最大滚动位置
|
|
|
|
+ requestAnimationFrame(() => {
|
|
|
|
+ const scrollLeft = smoothAnimationState.osdmScrollDom!.scrollLeft
|
|
|
|
+ smoothAnimationState.osdmScrollDom!.scrollLeft = scrollLeft + smoothAnimationState.translateXNum
|
|
|
|
+ smoothAnimationState.translateXNum = 0
|
|
|
|
+ });
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|