Browse Source

implemented getRowByY

Ievgen Naida 5 năm trước cách đây
mục cha
commit
94ba6b6d52
1 tập tin đã thay đổi với 12 bổ sung0 xóa
  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
    */