Skip to content

Commit 85f23a1

Browse files
authored
fix(module:carousel): correctly switch slides in RTL (#8705)
1 parent 845cdcc commit 85f23a1

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

components/carousel/carousel.component.ts

+2-14
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ const NZ_CONFIG_MODULE_NAME: NzConfigKey = 'carousel';
8787
[class.slick-dots-right]="nzDotPosition === 'right'"
8888
>
8989
@for (content of carouselContents; track content) {
90-
<li [class.slick-active]="$index === activeIndex" (click)="onLiClick($index)">
90+
<li [class.slick-active]="$index === activeIndex" (click)="goTo($index)">
9191
<ng-template
9292
[ngTemplateOutlet]="nzDotRender || renderDotTemplate"
9393
[ngTemplateOutletContext]="{ $implicit: $index }"
@@ -288,14 +288,6 @@ export class NzCarouselComponent implements AfterContentInit, AfterViewInit, OnD
288288
this.destroy$.complete();
289289
}
290290

291-
onLiClick = (index: number): void => {
292-
if (this.dir === 'rtl') {
293-
this.goTo(this.carouselContents.length - 1 - index);
294-
} else {
295-
this.goTo(index);
296-
}
297-
};
298-
299291
next(): void {
300292
this.goTo(this.activeIndex + 1);
301293
}
@@ -365,11 +357,7 @@ export class NzCarouselComponent implements AfterContentInit, AfterViewInit, OnD
365357

366358
if (this.carouselContents) {
367359
this.carouselContents.forEach((slide, i) => {
368-
if (this.dir === 'rtl') {
369-
slide.isActive = index === this.carouselContents.length - 1 - i;
370-
} else {
371-
slide.isActive = index === i;
372-
}
360+
slide.isActive = index === i;
373361
});
374362
}
375363

0 commit comments

Comments
 (0)