瀏覽代碼

Merge branch 'hqyDevNewVersion' of http://git.dayaedu.com/liushengqiang/music-score into feature-tianyong-newVersion

TIANYONG 11 月之前
父節點
當前提交
26d5fff5c4
共有 1 個文件被更改,包括 5 次插入2 次删除
  1. 5 2
      src/page-instrument/view-detail/smoothAnimation/index.ts

+ 5 - 2
src/page-instrument/view-detail/smoothAnimation/index.ts

@@ -74,7 +74,8 @@ export function initSmoothAnimation() {
       }
       return path
    }, 0)
-   smoothAnimationState.aveSpeed = (canvasDomPath / (state.times[state.times.length - 1].time - state.times[0].time) / 1000) * 16.67
+   // 20 是屏幕多长时间刷新一次的时间,本来是16.67的,但是有些手机帧率比较低,所以这里给小一点的值,宁愿慢一点偏屏幕左边一点
+   smoothAnimationState.aveSpeed = (canvasDomPath / (state.times[state.times.length - 1].time - state.times[0].time) / 1000) * 20
    // 当前屏幕的宽度
    calcClientWidth()
    window.addEventListener("resize", calcClientWidth)
@@ -129,7 +130,9 @@ export function moveSmoothAnimationByPlayTime(time?: number) {
       (nextIndex > state.times.length - 1 ? state.times[state.activeNoteIndex]?.endtime : state.times[nextIndex].time) -
       state.times[state.activeNoteIndex]?.time
    // 当前时值在该区间的占比
-   const playProgress = (currentTime - state.times[state.activeNoteIndex]?.time) / noteDuration
+   let playProgress = (currentTime - state.times[state.activeNoteIndex]?.time) / noteDuration
+   // 华为手机 fixtime 有个默认0.08的值,所以进度可能为负数 ,这里兼容一下
+   playProgress < 0 && (playProgress = 0)
    moveSmoothAnimation(playProgress, state.activeNoteIndex)
 }