Skip to content

Commit

Permalink
fix(esl-carousel): fix ESLCarouselNavDots livecycle and carousel obse…
Browse files Browse the repository at this point in the history
…rvation
  • Loading branch information
ala-n committed Jul 16, 2024
1 parent 2a41d67 commit c03c8f9
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/modules/esl-carousel/plugin/dots/esl-carousel.nav.dots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export class ESLCarouselNavDots extends ESLBaseElement {
*/
@memoize()
public get count(): number {
if (!this.$carousel) return 0;
if (!this.$carousel?.renderer) return 0;
const {count, size} = this.$carousel.state;
const value = Math.ceil(size / count);
return value > 1 ? value : 0;
Expand All @@ -94,7 +94,7 @@ export class ESLCarouselNavDots extends ESLBaseElement {
/** Active dot index according to carousel config. (Note: memoization used during update stage) */
@memoize()
public get activeIndex(): number {
if (!this.$carousel) return 0;
if (!this.$carousel?.renderer) return 0;
const {activeIndex, count, size} = this.$carousel.state;
return indexToGroup(activeIndex, count, size);
}
Expand Down Expand Up @@ -131,11 +131,9 @@ export class ESLCarouselNavDots extends ESLBaseElement {
}

@ready
public override async connectedCallback(): Promise<void> {
this.replaceChildren();
if (!this.$carousel) return;
await customElements.whenDefined(this.$carousel.tagName.toLowerCase());
public override connectedCallback(): void {
super.connectedCallback();
this.replaceChildren();
this.update();
this.updateA11y();
}
Expand All @@ -149,7 +147,6 @@ export class ESLCarouselNavDots extends ESLBaseElement {
if (!this.connected) return;
if (name === 'target') {
memoize.clear(this, '$carousel');
this.$$off(this._onSlideChange);
this.$$on(this._onSlideChange);
}
this.update();
Expand Down

0 comments on commit c03c8f9

Please sign in to comment.