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
+13 -9
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';
@@ -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];
} }