Skip to content

Commit

Permalink
fix(esl-carousel): fix slide mixin initialization order
Browse files Browse the repository at this point in the history
  • Loading branch information
ala-n committed Aug 22, 2024
1 parent 382fb98 commit ad92042
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 10 additions & 5 deletions src/modules/esl-carousel/core/esl-carousel.slide.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,28 @@ export class ESLCarouselSlide extends ESLMixinElement {

/** @returns slide index. */
public get index(): number {
return this.$carousel!.indexOf(this.$host);
if (typeof this.$carousel?.indexOf !== 'function') return -1;
return this.$carousel.indexOf(this.$host);
}
/** @returns whether the slide is active */
public get active(): boolean {
return this.$carousel!.isActive(this.$host);
if (typeof this.$carousel?.isActive !== 'function') return false;
return this.$carousel.isActive(this.$host);
}
/** @returns whether the slide is in pre-active state */
public get preActive(): boolean {
return this.$carousel!.isPreActive(this.$host);
if (typeof this.$carousel?.isPreActive !== 'function') return false;
return this.$carousel.isPreActive(this.$host);
}
/** @returns whether the slide is next in navigation */
public get next(): boolean {
return this.$carousel!.isNext(this.$host);
if (typeof this.$carousel?.isNext !== 'function') return false;
return this.$carousel.isNext(this.$host);
}
/** @returns whether the slide is previous in navigation*/
public get prev(): boolean {
return this.$carousel!.isPrev(this.$host);
if (typeof this.$carousel?.isPrev !== 'function') return false;
return this.$carousel.isPrev(this.$host);
}

/** Class(-es) to add on carousel container when slide is active. Supports {@link CSSClassUtils} syntax */
Expand Down
2 changes: 1 addition & 1 deletion src/modules/esl-carousel/core/esl-carousel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,9 @@ export class ESLCarousel extends ESLBaseElement {
* @param tagName - custom tag name to register custom element
*/
public static override register(tagName?: string): void {
super.register(tagName);
ESLCarouselSlide.is = this.is + '-slide';
ESLCarouselSlide.register();
super.register(tagName);
}
}

Expand Down

0 comments on commit ad92042

Please sign in to comment.