Always rescroll after the carousel is re-initalized.

This commit is contained in:
Dermot Duffy
2022-04-09 07:57:30 -07:00
parent f20bd8202f
commit 79bf66d961
2 changed files with 7 additions and 3 deletions
+1 -1
View File
@@ -26,7 +26,7 @@
"crypto": "^1.0.1",
"custom-card-helpers": "^1.9.0",
"date-fns": "^2.28.0",
"embla-carousel": "^6.1.1",
"embla-carousel": "^6.2.0",
"embla-carousel-wheel-gestures": "^2.1.1",
"home-assistant-js-websocket": "^6.1.1",
"keycharm": "^0.4.0",
+6 -2
View File
@@ -75,6 +75,11 @@ export class FrigateCardThumbnailCarousel extends FrigateCardCarousel {
protected _resizeHandler(): void {
if (this._carousel) {
this._carousel.reInit();
// Reinit will cause the scroll position to reset, so re-scroll to the
// correct location.
if (this._selected !== undefined && this._selected !== null) {
this.carouselScrollTo(this._selected);
}
}
}
@@ -102,7 +107,7 @@ export class FrigateCardThumbnailCarousel extends FrigateCardCarousel {
return {
containScroll: 'keepSnaps',
dragFree: true,
startIndex: this._selected ?? 0,
startIndex: this._selected ?? undefined,
};
}
@@ -139,7 +144,6 @@ export class FrigateCardThumbnailCarousel extends FrigateCardCarousel {
this.updateComplete.then(() => {
if (this._carousel) {
if (this._selected !== undefined && this._selected !== null) {
console.info('thumbnail carousel scroll to')
this.carouselScrollTo(this._selected);
}
}