瀏覽代碼

兼容音符的x坐标可能是 -Infinity, Infinity 的问题

黄琪勇 10 月之前
父節點
當前提交
2cf00d90b9
共有 1 個文件被更改,包括 2 次插入2 次删除
  1. 2 2
      src/page-instrument/view-detail/smoothAnimation/index.ts

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

@@ -368,7 +368,7 @@ function getPointsPosByBatePos(): pointsPosType {
    const frequencyLineData = quantileScale(frequencyData, 8, _canvasDomHeight - 8) // 最小值和最大值
    const pointsPos = state.times.reduce((posArr: any[], item, index) => {
       // 当休止小节,可能当前音符在谱面上没有实际的音符(没有bbox)
-      if (item.bbox?.x != null && item.noteId != null) {
+      if (item.bbox?.x != null && ![-Infinity, Infinity].includes(item.bbox?.x) && item.noteId != null) {
          posArr.push({
             noteId: item.noteId,
             MeasureNumberXML: item.MeasureNumberXML,
@@ -381,7 +381,7 @@ function getPointsPosByBatePos(): pointsPosType {
             // 这里当第一个音符noteId为null,找不到前一个noteId,所以兼容一下
             noteId: item.noteId != null ? item.noteId : (posArr[posArr.length - 1]?.noteId != null ? posArr[posArr.length - 1]?.noteId : -1) + 0.01, // 这里+0.01 是制造一个假id
             MeasureNumberXML: item.MeasureNumberXML,
-            x: item.bbox?.x != null ? item.bbox.x : posArr[posArr.length - 1]?.x || 10,
+            x: item.bbox?.x != null && ![-Infinity, Infinity].includes(item.bbox?.x) ? item.bbox.x : posArr[posArr.length - 1]?.x || 10,
             y: _canvasDomHeight - frequencyLineData[index]
          })
       }