Add card-wide action support for timeline.

This commit is contained in:
Dermot Duffy
2022-04-10 15:07:39 -07:00
parent e3ef1a9657
commit e3e7646fea
4 changed files with 16 additions and 0 deletions
+12
View File
@@ -13,6 +13,7 @@ import { DataSet } from 'vis-data/esnext';
import {
DataGroupCollectionType,
Timeline,
TimelineEventPropertiesResult,
TimelineItem,
TimelineOptions,
TimelineOptionsCluster,
@@ -40,6 +41,7 @@ import {
dispatchErrorMessageEvent,
dispatchFrigateCardEvent,
getCameraTitle,
stopEventFromActivatingCardWideActions,
} from '../common.js';
import timelineCoreStyle from '../scss/timeline-core.scss';
@@ -428,6 +430,14 @@ export class FrigateCardTimelineCore extends LitElement {
></div>`;
}
protected _timelineClickHandler(properties: TimelineEventPropertiesResult): void {
if (properties.what === 'item') {
// Prevent interaction with items on the timeline from activating card
// wide actions.
stopEventFromActivatingCardWideActions(properties.event);
}
}
/**
* Handle a range change in the timeline.
* @param properties vis.js provided range information.
@@ -807,6 +817,8 @@ export class FrigateCardTimelineCore extends LitElement {
);
this._timeline.on('select', this._timelineSelectHandler.bind(this));
this._timeline.on('rangechanged', this._timelineRangeHandler.bind(this));
this._timeline.on('click', this._timelineClickHandler.bind(this));
this._timeline.on('doubleclick', this._timelineClickHandler.bind(this));
}
}