Main live camera carousel should loop.

This commit is contained in:
Dermot Duffy
2022-02-06 12:30:44 -08:00
parent 5bf9ab23ae
commit ee6c364e32
+15 -11
View File
@@ -34,7 +34,10 @@ import { BrowseMediaUtil } from '../browse-media-util.js';
import { ConditionState, getOverriddenConfig } from '../card-condition.js'; import { ConditionState, getOverriddenConfig } from '../card-condition.js';
import { FrigateCardMediaCarousel } from './media-carousel.js'; import { FrigateCardMediaCarousel } from './media-carousel.js';
import { FrigateCardNextPreviousControl } from './next-prev-control.js'; import { FrigateCardNextPreviousControl } from './next-prev-control.js';
import { FrigateCardThumbnailCarousel, ThumbnailCarouselTap } from './thumbnail-carousel.js'; import {
FrigateCardThumbnailCarousel,
ThumbnailCarouselTap,
} from './thumbnail-carousel.js';
import { Lazyload } from './embla-plugins/lazyload.js'; import { Lazyload } from './embla-plugins/lazyload.js';
import { View } from '../view.js'; import { View } from '../view.js';
import { localize } from '../localize/localize.js'; import { localize } from '../localize/localize.js';
@@ -174,10 +177,10 @@ export class FrigateCardLive extends LitElement {
// up/down as the thumbnails disappear and re-appear. Instead, if there was // up/down as the thumbnails disappear and re-appear. Instead, if there was
// previously a thumbnail carousel rendered, use a filler that is the same // previously a thumbnail carousel rendered, use a filler that is the same
// size until it is replaced with a real carousel (or empty, if no carousel // size until it is replaced with a real carousel (or empty, if no carousel
// is rendered for the next camera). // is rendered for the next camera).
return html`${until( return html`${until(
fetchThumbnailsThenRender(), fetchThumbnailsThenRender(),
this._thumbnailCarousel this._thumbnailCarousel
? html` <div style="${styleMap(fillerStyle)}"></div>` ? html` <div style="${styleMap(fillerStyle)}"></div>`
: html``, : html``,
)}`; )}`;
@@ -324,6 +327,7 @@ export class FrigateCardLiveCarousel extends FrigateCardMediaCarousel {
return { return {
startIndex: startIndex < 0 ? undefined : startIndex, startIndex: startIndex < 0 ? undefined : startIndex,
draggable: this.liveConfig?.draggable, draggable: this.liveConfig?.draggable,
loop: true,
}; };
} }
@@ -474,14 +478,14 @@ export class FrigateCardLiveCarousel extends FrigateCardMediaCarousel {
return [null, null]; return [null, null];
} }
let prev: CameraConfig | null = null, const prev =
next: CameraConfig | null = null; this.cameras.get(
if (currentIndex > 0) { keys[currentIndex > 0 ? currentIndex - 1 : this.cameras.size - 1],
prev = this.cameras.get(keys[currentIndex - 1]) ?? null; ) ?? null;
} const next =
if (currentIndex + 1 < this.cameras.size) { this.cameras.get(
next = this.cameras.get(keys[currentIndex + 1]) ?? null; keys[currentIndex + 1 < this.cameras.size ? currentIndex + 1 : 0],
} ) ?? null;
return [prev, next]; return [prev, next];
} }