Reset the carousel of the plugins/options change.

This commit is contained in:
Dermot Duffy
2022-07-10 20:05:18 -07:00
parent 898a46fda2
commit 214a553aa7
5 changed files with 91 additions and 74 deletions
+19
View File
@@ -65,6 +65,21 @@ export class FrigateCardCarousel extends LitElement {
super.disconnectedCallback();
}
/**
* Destroy the carousel if certain properties change.
* @param changedProps The changed properties
*/
protected willUpdate(changedProps: PropertyValues): void {
const destroyProperties = [
'direction',
'carouselOptions',
'carouselOptions',
] as const;
if (destroyProperties.some((prop) => changedProps.has(prop))) {
this._destroyCarousel();
}
}
/**
* Scroll to a particular slide.
* @param index Slide number.
@@ -193,6 +208,10 @@ export class FrigateCardCarousel extends LitElement {
index: selected,
});
}
// Make sure every select causes a refresh to allow for re-paint of the
// next/previous controls.
this.requestUpdate();
});
}
}