Browse Source

implemented getRowByY

Ievgen Naida 5 years ago
parent
commit
94ba6b6d52
1 changed files with 12 additions and 0 deletions
  1. 12 0
      src/timeline.ts

+ 12 - 0
src/timeline.ts

@@ -1428,6 +1428,18 @@ export class Timeline extends TimelineEventsEmitter {
     this.renderTimeline();
   };
 
+  /**
+   * Get row by y coordinate.
+   * @param posY y screen coordinate.
+   */
+  public getRowByY(posY: number): TimelineRow {
+    const model = this.calculateRowsBounds();
+    if (model && model.rows) {
+      return model.rows.find((rowData) => rowData.y >= posY && posY <= rowData.y + rowData.height);
+    }
+
+    return null;
+  }
   /**
    * Find sharp pixel position
    */