From 046313eb47afbf667e92b0bee05b97e111d3ecb0 Mon Sep 17 00:00:00 2001 From: Dermot Duffy Date: Sun, 25 Sep 2022 18:03:57 -0700 Subject: [PATCH] Add comment. --- src/components/carousel.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/carousel.ts b/src/components/carousel.ts index 3a1fbbc4..0afb657f 100644 --- a/src/components/carousel.ts +++ b/src/components/carousel.ts @@ -105,13 +105,16 @@ export class FrigateCardCarousel extends LitElement { * @param index Slide number. */ public carouselScrollTo(index: number): void { - const scroll = () => this._carousel?.scrollTo(index, this.transitionEffect === 'none'); + const scroll = () => + this._carousel?.scrollTo(index, this.transitionEffect === 'none'); + // This ensures scrolling can work on initial render when the carousel may + // not yet exist. if (this._carousel) { scroll(); } else { this.updateComplete.then(() => { scroll(); - }) + }); } }