From 0d7adce75833b6fc9794f4230667494d0b59a837 Mon Sep 17 00:00:00 2001 From: Ann Barmina Date: Wed, 31 Jul 2024 23:20:08 +0200 Subject: [PATCH] fix(esl-carousel): fix incomplete centered carousel rendering Co-authored-by: ala'n (Alexey Stsefanovich) --- .../renderers/esl-carousel.centered.renderer.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/modules/esl-carousel/renderers/esl-carousel.centered.renderer.ts b/src/modules/esl-carousel/renderers/esl-carousel.centered.renderer.ts index 805a136f2..40d3a0c8c 100644 --- a/src/modules/esl-carousel/renderers/esl-carousel.centered.renderer.ts +++ b/src/modules/esl-carousel/renderers/esl-carousel.centered.renderer.ts @@ -12,10 +12,11 @@ export class ESLCenteredCarouselRenderer extends ESLDefaultCarouselRenderer { public static override is = 'centered'; public static override classes: string[] = ['esl-carousel-centered-renderer', 'esl-carousel-default-renderer']; - /** @returns size of all active slides */ + /** Size of all active slides */ public get activeSlidesSize(): number { - let width = (this.count - 1) * this.gap; - for (let i = 0; i < this.count; i++) { + const count = Math.min(this.count, this.size); + let width = (count - 1) * this.gap; + for (let i = 0; i < count; i++) { const position = normalize(i + this.currentIndex, this.size); const $slide = this.$slides[position]; width += this.vertical ? $slide.offsetHeight : $slide.offsetWidth; @@ -23,12 +24,12 @@ export class ESLCenteredCarouselRenderer extends ESLDefaultCarouselRenderer { return width; } - /** @returns carousel size */ + /** Carousel size */ public get carouselSize(): number { return this.vertical ? this.$carousel.clientHeight : this.$carousel.clientWidth; } - /** @returns carousel padding value */ + /** Carousel padding value */ public get carouselPadding(): number { const carouselStyles = getComputedStyle(this.$carousel); return parseFloat(carouselStyles[this.vertical ? 'paddingTop' : 'paddingLeft']);