Reduce number of event listeners.

This commit is contained in:
Dermot Duffy
2023-08-09 21:32:53 -07:00
parent 330f927fdb
commit fe2adb5b89
2 changed files with 10 additions and 18 deletions
+10 -16
View File
@@ -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, {
capture: true,
});
}
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, {
capture: true,
});
}
protected _removeChildEventListeners(child: MediaGridChild): void {
child.removeEventListener('click', this._handleSelectGridCellEvent, {
capture: true,
});
child.addEventListener(
child.removeEventListener(
'frigate-card:media:loaded',
this._handleMediaLoadedInfoEvent,
);