Don't use wheel plugin when there's only one media item.

This commit is contained in:
Dermot Duffy
2022-06-05 16:10:43 -07:00
parent 84997077bc
commit 994973dded
4 changed files with 48 additions and 13 deletions
+18 -1
View File
@@ -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 { customElement, property, state } from 'lit/decorators.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.
* @returns The slides to include in the render.