Pārlūkot izejas kodu

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 gadi atpakaļ
vecāks
revīzija
f20cd6760c
1 mainītis faili ar 2 papildinājumiem un 2 dzēšanām
  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));