浏览代码

implemented getRowByY

Ievgen Naida 5 年之前
父节点
当前提交
94ba6b6d52
共有 1 个文件被更改,包括 12 次插入0 次删除
  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
    */