Include mouse movements as interaction.
This commit is contained in:
+18
-5
@@ -6,12 +6,13 @@ import {
|
|||||||
html,
|
html,
|
||||||
unsafeCSS,
|
unsafeCSS,
|
||||||
} from 'lit';
|
} from 'lit';
|
||||||
|
import { HomeAssistant, LovelaceCardEditor, getLovelace } from 'custom-card-helpers';
|
||||||
|
import { StyleInfo, styleMap } from 'lit/directives/style-map.js';
|
||||||
import { customElement, property, query, state } from 'lit/decorators.js';
|
import { customElement, property, query, state } from 'lit/decorators.js';
|
||||||
import { classMap } from 'lit/directives/class-map.js';
|
import { classMap } from 'lit/directives/class-map.js';
|
||||||
import { StyleInfo, styleMap } from 'lit/directives/style-map.js';
|
|
||||||
import { until } from 'lit/directives/until.js';
|
|
||||||
import { HomeAssistant, LovelaceCardEditor, getLovelace } from 'custom-card-helpers';
|
|
||||||
import screenfull from 'screenfull';
|
import screenfull from 'screenfull';
|
||||||
|
import { throttle } from 'lodash-es';
|
||||||
|
import { until } from 'lit/directives/until.js';
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -180,6 +181,10 @@ export class FrigateCard extends LitElement {
|
|||||||
// A cache of resolved media URLs/mimetypes for use in the whole card.
|
// A cache of resolved media URLs/mimetypes for use in the whole card.
|
||||||
protected _resolvedMediaCache = new ResolvedMediaCache();
|
protected _resolvedMediaCache = new ResolvedMediaCache();
|
||||||
|
|
||||||
|
// The mouse handler may be called continually, throttle it to at most once
|
||||||
|
// per second for performance reasons.
|
||||||
|
protected _boundMouseHandler = throttle(this._mouseHandler.bind(this), 1 * 1000);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the Home Assistant object.
|
* Set the Home Assistant object.
|
||||||
*/
|
*/
|
||||||
@@ -383,8 +388,7 @@ export class FrigateCard extends LitElement {
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
this._getConfig().menu.buttons.download &&
|
this._getConfig().menu.buttons.download &&
|
||||||
(this._view?.isViewerView() || this._view?.is('timeline') &&
|
(this._view?.isViewerView() || (this._view?.is('timeline') && !!this._view?.media))
|
||||||
!!this._view?.media)
|
|
||||||
) {
|
) {
|
||||||
buttons.push({
|
buttons.push({
|
||||||
type: 'custom:frigate-card-menu-icon',
|
type: 'custom:frigate-card-menu-icon',
|
||||||
@@ -935,6 +939,13 @@ export class FrigateCard extends LitElement {
|
|||||||
this._startInteractionTimer();
|
this._startInteractionTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle mouse movements.
|
||||||
|
*/
|
||||||
|
protected _mouseHandler(): void {
|
||||||
|
this._startInteractionTimer();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear the user interaction ('screensaver') timer.
|
* Clear the user interaction ('screensaver') timer.
|
||||||
*/
|
*/
|
||||||
@@ -1071,6 +1082,7 @@ export class FrigateCard extends LitElement {
|
|||||||
if (screenfull.isEnabled) {
|
if (screenfull.isEnabled) {
|
||||||
screenfull.on('change', this._fullscreenHandler.bind(this));
|
screenfull.on('change', this._fullscreenHandler.bind(this));
|
||||||
}
|
}
|
||||||
|
this.addEventListener('mousemove', this._boundMouseHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1080,6 +1092,7 @@ export class FrigateCard extends LitElement {
|
|||||||
if (screenfull.isEnabled) {
|
if (screenfull.isEnabled) {
|
||||||
screenfull.off('change', this._fullscreenHandler.bind(this));
|
screenfull.off('change', this._fullscreenHandler.bind(this));
|
||||||
}
|
}
|
||||||
|
this.removeEventListener('mousemove', this._boundMouseHandler);
|
||||||
super.disconnectedCallback();
|
super.disconnectedCallback();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// TODO: Periodically refetch events.
|
|
||||||
// TODO: Editor support for timeline (incl. in views).
|
// TODO: Editor support for timeline (incl. in views).
|
||||||
// TODO: Make thumbnail controls optional (in all places that use thumbnails).
|
// TODO: Make thumbnail controls optional (in all places that use thumbnails).
|
||||||
// TODO: Search for TODOs and logging statements.
|
// TODO: Search for TODOs and logging statements.
|
||||||
@@ -507,7 +506,7 @@ export class FrigateCardTimelineCore extends LitElement {
|
|||||||
const selected = this._timeline.getSelection();
|
const selected = this._timeline.getSelection();
|
||||||
let childIndex = -1;
|
let childIndex = -1;
|
||||||
const children: FrigateBrowseMediaSource[] = [];
|
const children: FrigateBrowseMediaSource[] = [];
|
||||||
this._events.dataset.get().forEach((item) => {
|
this._events.dataset.get({order: 'start'}).forEach((item) => {
|
||||||
if (this.timelineConfig) {
|
if (this.timelineConfig) {
|
||||||
let added = false;
|
let added = false;
|
||||||
if (
|
if (
|
||||||
@@ -732,15 +731,13 @@ export class FrigateCardTimelineCore extends LitElement {
|
|||||||
this._generateThumbnails();
|
this._generateThumbnails();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event) {
|
this._timeline.setSelection(event ? [event.id] : [], {
|
||||||
this._timeline.setSelection([event.id], {
|
focus: false,
|
||||||
focus: false,
|
animation: {
|
||||||
animation: {
|
animation: false,
|
||||||
animation: false,
|
zoom: false,
|
||||||
zoom: false,
|
},
|
||||||
},
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const context = this.view.context as TimelineViewContext | null;
|
const context = this.view.context as TimelineViewContext | null;
|
||||||
const timelineWindow = this._timeline.getWindow();
|
const timelineWindow = this._timeline.getWindow();
|
||||||
|
|||||||
Reference in New Issue
Block a user