浏览代码

refactor: options.pageFormat now uses osmd.setPageFormat, instead of duplicated code

updated outdated comment, which triggered this change.
before, checking options.pageFormat basically duplicated the code of osmd.setPageFormat, but not entirely.

The change doesn't do functional changes for now, because osmd.needBackendUpdate is currently unused,
but this is cleaner in any case.
sschmid 5 年之前
父节点
当前提交
f20cd6760c
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      src/OpenSheetMusicDisplay/OpenSheetMusicDisplay.ts

+ 2 - 2
src/OpenSheetMusicDisplay/OpenSheetMusicDisplay.ts

@@ -503,7 +503,7 @@ export class OpenSheetMusicDisplay {
             // we could remove the window EventListener here, but not necessary.
         }
         if (options.pageFormat !== undefined) { // only change this option if it was given, see above
-            this.rules.PageFormat = OpenSheetMusicDisplay.StringToPageFormat(options.pageFormat);
+            this.setPageFormat(options.pageFormat);
         }
         if (options.pageBackgroundColor !== undefined) {
             this.rules.PageBackgroundColor = options.pageBackgroundColor;
@@ -761,7 +761,7 @@ export class OpenSheetMusicDisplay {
         return pageFormat;
     }
 
-    /** Sets page format by string. Alternative to setOptions({pageFormat: PageFormatStandards.Endless}) for example. */
+    /** Sets page format by string. Used by setOptions({pageFormat: "A4_P"}) for example. */
     public setPageFormat(formatId: string): void {
         const newPageFormat: PageFormat = OpenSheetMusicDisplay.StringToPageFormat(formatId);
         this.needBackendUpdate = !(newPageFormat.Equals(this.rules.PageFormat));