Don't use wheel plugin when there's only one media item.
This commit is contained in:
@@ -3,7 +3,6 @@ import EmblaCarousel, {
|
|||||||
EmblaOptionsType,
|
EmblaOptionsType,
|
||||||
EmblaPluginType
|
EmblaPluginType
|
||||||
} from 'embla-carousel';
|
} from 'embla-carousel';
|
||||||
import { WheelGesturesPlugin } from 'embla-carousel-wheel-gestures';
|
|
||||||
import { CSSResultGroup, LitElement, PropertyValues, unsafeCSS } from 'lit';
|
import { CSSResultGroup, LitElement, PropertyValues, unsafeCSS } from 'lit';
|
||||||
import { property } from 'lit/decorators.js';
|
import { property } from 'lit/decorators.js';
|
||||||
import carouselStyle from '../scss/carousel.scss';
|
import carouselStyle from '../scss/carousel.scss';
|
||||||
@@ -72,16 +71,10 @@ export class FrigateCardCarousel extends LitElement {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Embla plugins to use.
|
* Get the Embla plugins to use.
|
||||||
* @returns An EmblaOptionsType object or undefined for no options.
|
* @returns A list of EmblaOptionsTypes.
|
||||||
*/
|
*/
|
||||||
protected _getPlugins(): EmblaPluginType[] {
|
protected _getPlugins(): EmblaPluginType[] {
|
||||||
return [
|
return [];
|
||||||
WheelGesturesPlugin({
|
|
||||||
// Whether the carousel is vertical or horizontal, interpret y-axis wheel
|
|
||||||
// gestures as scrolling for the carousel.
|
|
||||||
forceWheelAxis: 'y',
|
|
||||||
}),
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected _destroyCarousel(): void {
|
protected _destroyCarousel(): void {
|
||||||
|
|||||||
+13
-2
@@ -2,6 +2,7 @@ import JSMpeg from '@cycjimmy/jsmpeg-player';
|
|||||||
import { Task } from '@lit-labs/task';
|
import { Task } from '@lit-labs/task';
|
||||||
import { HomeAssistant } from 'custom-card-helpers';
|
import { HomeAssistant } from 'custom-card-helpers';
|
||||||
import { EmblaOptionsType, EmblaPluginType } from 'embla-carousel';
|
import { EmblaOptionsType, EmblaPluginType } from 'embla-carousel';
|
||||||
|
import { WheelGesturesPlugin } from 'embla-carousel-wheel-gestures';
|
||||||
import {
|
import {
|
||||||
CSSResultGroup,
|
CSSResultGroup,
|
||||||
html,
|
html,
|
||||||
@@ -287,11 +288,21 @@ export class FrigateCardLiveCarousel extends FrigateCardMediaCarousel {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Embla plugins to use.
|
* Get the Embla plugins to use.
|
||||||
* @returns An EmblaOptionsType object or undefined for no options.
|
* @returns A list of EmblaOptionsTypes.
|
||||||
*/
|
*/
|
||||||
protected _getPlugins(): EmblaPluginType[] {
|
protected _getPlugins(): EmblaPluginType[] {
|
||||||
return [
|
return [
|
||||||
...super._getPlugins(),
|
...super._getPlugins(),
|
||||||
|
// Only enable wheel plugin if there is more than one camera.
|
||||||
|
...(this.cameras && this.cameras.size > 1
|
||||||
|
? [
|
||||||
|
WheelGesturesPlugin({
|
||||||
|
// Whether the carousel is vertical or horizontal, interpret y-axis wheel
|
||||||
|
// gestures as scrolling for the carousel.
|
||||||
|
forceWheelAxis: 'y',
|
||||||
|
}),
|
||||||
|
]
|
||||||
|
: []),
|
||||||
Lazyload({
|
Lazyload({
|
||||||
...(this.liveConfig?.lazy_load && {
|
...(this.liveConfig?.lazy_load && {
|
||||||
lazyLoadCallback: (index, slide) =>
|
lazyLoadCallback: (index, slide) =>
|
||||||
@@ -893,7 +904,7 @@ export class FrigateCardLiveWebRTCCard extends LitElement {
|
|||||||
e instanceof FrigateCardError
|
e instanceof FrigateCardError
|
||||||
? e.message
|
? e.message
|
||||||
: localize('error.webrtc_card_reported_error') + ': ' + (e as Error).message,
|
: localize('error.webrtc_card_reported_error') + ': ' + (e as Error).message,
|
||||||
(e as FrigateCardError).context
|
(e as FrigateCardError).context,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return html`${webrtcElement}`;
|
return html`${webrtcElement}`;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { EmblaOptionsType } from 'embla-carousel';
|
import { EmblaOptionsType, EmblaPluginType } from 'embla-carousel';
|
||||||
|
import { WheelGesturesPlugin } from 'embla-carousel-wheel-gestures';
|
||||||
import { CSSResultGroup, html, PropertyValues, TemplateResult, unsafeCSS } from 'lit';
|
import { CSSResultGroup, html, PropertyValues, TemplateResult, unsafeCSS } from 'lit';
|
||||||
import { customElement, property, state } from 'lit/decorators.js';
|
import { customElement, property, state } from 'lit/decorators.js';
|
||||||
import { classMap } from 'lit/directives/class-map.js';
|
import { classMap } from 'lit/directives/class-map.js';
|
||||||
@@ -100,6 +101,22 @@ export class FrigateCardThumbnailCarousel extends FrigateCardCarousel {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Embla plugins to use.
|
||||||
|
* @returns A list of EmblaOptionsTypes.
|
||||||
|
*/
|
||||||
|
protected _getPlugins(): EmblaPluginType[] {
|
||||||
|
return [
|
||||||
|
...super._getPlugins(),
|
||||||
|
// Only enable wheel plugin if there is more than one camera.
|
||||||
|
WheelGesturesPlugin({
|
||||||
|
// Whether the carousel is vertical or horizontal, interpret y-axis wheel
|
||||||
|
// gestures as scrolling for the carousel.
|
||||||
|
forceWheelAxis: 'y',
|
||||||
|
}),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get slides to include in the render.
|
* Get slides to include in the render.
|
||||||
* @returns The slides to include in the render.
|
* @returns The slides to include in the render.
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { Task } from '@lit-labs/task';
|
import { Task } from '@lit-labs/task';
|
||||||
import { EmblaOptionsType, EmblaPluginType } from 'embla-carousel';
|
import { EmblaOptionsType, EmblaPluginType } from 'embla-carousel';
|
||||||
|
import { WheelGesturesPlugin } from 'embla-carousel-wheel-gestures';
|
||||||
import {
|
import {
|
||||||
CSSResultGroup,
|
CSSResultGroup,
|
||||||
html,
|
html,
|
||||||
@@ -296,11 +297,24 @@ export class FrigateCardViewerCarousel extends FrigateCardMediaCarousel {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Embla plugins to use.
|
* Get the Embla plugins to use.
|
||||||
* @returns An EmblaOptionsType object or undefined for no options.
|
* @returns A list of EmblaOptionsTypes.
|
||||||
*/
|
*/
|
||||||
protected _getPlugins(): EmblaPluginType[] {
|
protected _getPlugins(): EmblaPluginType[] {
|
||||||
return [
|
return [
|
||||||
...super._getPlugins(),
|
...super._getPlugins(),
|
||||||
|
// Only enable wheel plugin if there is more than one media item.
|
||||||
|
...(this.view &&
|
||||||
|
this.view.target &&
|
||||||
|
this.view.target.children &&
|
||||||
|
this.view.target.children.length > 1
|
||||||
|
? [
|
||||||
|
WheelGesturesPlugin({
|
||||||
|
// Whether the carousel is vertical or horizontal, interpret y-axis wheel
|
||||||
|
// gestures as scrolling for the carousel.
|
||||||
|
forceWheelAxis: 'y',
|
||||||
|
}),
|
||||||
|
]
|
||||||
|
: []),
|
||||||
Lazyload({
|
Lazyload({
|
||||||
...(this.viewerConfig?.lazy_load && {
|
...(this.viewerConfig?.lazy_load && {
|
||||||
lazyLoadCallback: this._lazyloadSlide.bind(this),
|
lazyLoadCallback: this._lazyloadSlide.bind(this),
|
||||||
|
|||||||
Reference in New Issue
Block a user