Reduce number of event listeners.
This commit is contained in:
@@ -2,8 +2,6 @@
|
|||||||
// TODO: Investigate query spam during a grid load
|
// TODO: Investigate query spam during a grid load
|
||||||
// TODO: Is the query reset in card.ts correct for media filter multi-camera queries that are not all cameras?
|
// TODO: Is the query reset in card.ts correct for media filter multi-camera queries that are not all cameras?
|
||||||
// TODO: Do I need column max?
|
// TODO: Do I need column max?
|
||||||
// TODO: Can SELECT_CHILD_EVENTS only be 'click' and it still work on Android?
|
|
||||||
// TODO: With live autoplay off only white frames appear?
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
CSSResultGroup,
|
CSSResultGroup,
|
||||||
|
|||||||
@@ -29,8 +29,6 @@ export interface MediaGridConstructorOptions {
|
|||||||
idAttribute?: string;
|
idAttribute?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SELECT_CHILD_EVENTS = ['click', 'touchend'];
|
|
||||||
|
|
||||||
export class MediaGridController {
|
export class MediaGridController {
|
||||||
protected _host: HTMLElement;
|
protected _host: HTMLElement;
|
||||||
|
|
||||||
@@ -216,27 +214,23 @@ export class MediaGridController {
|
|||||||
this._throttledLayout();
|
this._throttledLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected _removeChildEventListeners(child: MediaGridChild): void {
|
protected _addChildEventListeners(child: MediaGridChild): void {
|
||||||
for (const event of SELECT_CHILD_EVENTS) {
|
child.addEventListener('click', this._handleSelectGridCellEvent, {
|
||||||
child.removeEventListener(event, this._handleSelectGridCellEvent, {
|
|
||||||
capture: true,
|
capture: true,
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
child.removeEventListener(
|
child.addEventListener(
|
||||||
'frigate-card:media:loaded',
|
'frigate-card:media:loaded',
|
||||||
this._handleMediaLoadedInfoEvent,
|
this._handleMediaLoadedInfoEvent,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected _addChildEventListeners(child: MediaGridChild): void {
|
protected _removeChildEventListeners(child: MediaGridChild): void {
|
||||||
for (const event of SELECT_CHILD_EVENTS) {
|
child.removeEventListener('click', this._handleSelectGridCellEvent, {
|
||||||
child.addEventListener(event, this._handleSelectGridCellEvent, {
|
|
||||||
capture: true,
|
capture: true,
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
child.addEventListener(
|
child.removeEventListener(
|
||||||
'frigate-card:media:loaded',
|
'frigate-card:media:loaded',
|
||||||
this._handleMediaLoadedInfoEvent,
|
this._handleMediaLoadedInfoEvent,
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user