浏览代码

fix undefined error (another) with drawUpToMeasureNumber set (#68)

sschmidTU 3 年之前
父节点
当前提交
236f6e5e50
共有 1 个文件被更改,包括 4 次插入2 次删除
  1. 4 2
      src/OpenSheetMusicDisplay/Cursor.ts

+ 4 - 2
src/OpenSheetMusicDisplay/Cursor.ts

@@ -248,9 +248,11 @@ export class Cursor implements IPlaybackListener {
 
     // y is common for both multirest and non-multirest, given the MusicSystem
     y = musicSystem.PositionAndShape.AbsolutePosition.y + musicSystem.StaffLines[0]?.PositionAndShape.RelativePosition.y ?? 0;
+    let endY: number = musicSystem.PositionAndShape.AbsolutePosition.y;
     const bottomStaffline: StaffLine = musicSystem.StaffLines[musicSystem.StaffLines.length - 1];
-    const endY: number = musicSystem.PositionAndShape.AbsolutePosition.y +
-    bottomStaffline.PositionAndShape.RelativePosition.y + bottomStaffline.StaffHeight;
+    if (bottomStaffline) {
+      endY += bottomStaffline.PositionAndShape.RelativePosition.y + bottomStaffline.StaffHeight;
+    }
     height = endY - y;
 
     // Update the graphical cursor