浏览代码

Added the option the follow the cursor (middle of the page)

Added both to OSMD properties and OSMD constructor options
praisethemoon 6 年之前
父节点
当前提交
fcddd15c13
共有 2 个文件被更改,包括 12 次插入0 次删除
  1. 2 0
      src/OpenSheetMusicDisplay/OSMDOptions.ts
  2. 10 0
      src/OpenSheetMusicDisplay/OpenSheetMusicDisplay.ts

+ 2 - 0
src/OpenSheetMusicDisplay/OSMDOptions.ts

@@ -33,6 +33,8 @@ export interface IOSMDOptions {
     defaultColorTitle?: string;
     /** Don't show/load cursor. Will override disableCursor in drawingParameters. */
     disableCursor?: boolean;
+    /** Follow Cursor */
+    followCursor?: boolean;
     /** Broad Parameters like compact or preview mode. */
     drawingParameters?: string | DrawingParametersEnum;
     /** Whether to draw credits (title, subtitle, composer, lyricist) (in future: copyright etc., see <credit>). */

+ 10 - 0
src/OpenSheetMusicDisplay/OpenSheetMusicDisplay.ts

@@ -72,6 +72,7 @@ export class OpenSheetMusicDisplay {
     private drawingParameters: DrawingParameters;
     private autoResizeEnabled: boolean;
     private resizeHandlerAttached: boolean;
+    private followCursor: boolean;
 
     /**
      * Load a MusicXML file
@@ -223,6 +224,7 @@ export class OpenSheetMusicDisplay {
             this.canvas = this.backend.getCanvas();
             this.innerElement = this.backend.getInnerElement();
             this.enableOrDisableCursor(this.drawingParameters.drawCursors);
+            this.followCursor = options.followCursor;
             // Create the drawer
             this.drawer = new VexFlowMusicSheetDrawer(this.canvas, this.backend, this.drawingParameters);
         }
@@ -547,6 +549,14 @@ export class OpenSheetMusicDisplay {
         this.autoResizeEnabled = value;
     }
 
+    public set FollowCursor(value: boolean) {
+        this.followCursor = value;
+    }
+
+    public get FollowCursor(): boolean {
+        return this.followCursor;
+    }
+
     public get Sheet(): MusicSheet {
         return this.sheet;
     }