Reduce number of event listeners.
This commit is contained in:
@@ -2,8 +2,6 @@
|
||||
// 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: 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 {
|
||||
CSSResultGroup,
|
||||
|
||||
@@ -29,8 +29,6 @@ export interface MediaGridConstructorOptions {
|
||||
idAttribute?: string;
|
||||
}
|
||||
|
||||
const SELECT_CHILD_EVENTS = ['click', 'touchend'];
|
||||
|
||||
export class MediaGridController {
|
||||
protected _host: HTMLElement;
|
||||
|
||||
@@ -216,27 +214,23 @@ export class MediaGridController {
|
||||
this._throttledLayout();
|
||||
}
|
||||
|
||||
protected _removeChildEventListeners(child: MediaGridChild): void {
|
||||
for (const event of SELECT_CHILD_EVENTS) {
|
||||
child.removeEventListener(event, this._handleSelectGridCellEvent, {
|
||||
protected _addChildEventListeners(child: MediaGridChild): void {
|
||||
child.addEventListener('click', this._handleSelectGridCellEvent, {
|
||||
capture: true,
|
||||
});
|
||||
}
|
||||
|
||||
child.removeEventListener(
|
||||
child.addEventListener(
|
||||
'frigate-card:media:loaded',
|
||||
this._handleMediaLoadedInfoEvent,
|
||||
);
|
||||
}
|
||||
|
||||
protected _addChildEventListeners(child: MediaGridChild): void {
|
||||
for (const event of SELECT_CHILD_EVENTS) {
|
||||
child.addEventListener(event, this._handleSelectGridCellEvent, {
|
||||
protected _removeChildEventListeners(child: MediaGridChild): void {
|
||||
child.removeEventListener('click', this._handleSelectGridCellEvent, {
|
||||
capture: true,
|
||||
});
|
||||
}
|
||||
|
||||
child.addEventListener(
|
||||
child.removeEventListener(
|
||||
'frigate-card:media:loaded',
|
||||
this._handleMediaLoadedInfoEvent,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user