Skip to content

Commit

Permalink
fix(module: carousel): fix set Carousel component selectedIndex( = la…
Browse files Browse the repository at this point in the history
…st) invalid (#315)
  • Loading branch information
nuonuoge authored and fisherspy committed Mar 4, 2019
1 parent a66be30 commit 193a4d6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions components/carousel/carousel.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class CarouselComponent implements AfterViewInit, OnDestroy {
return this._selectedIndex;
}
set selectedIndex(value) {
this._selectedIndex = value;
this._selectedIndex = Math.abs(value);
if (this._nodeArr.length > 0) {
this.carousel(1);
}
Expand Down Expand Up @@ -475,9 +475,10 @@ export class CarouselComponent implements AfterViewInit, OnDestroy {
this.carouselInit(items);
});
this.initCarouselSize();
const index = this.items.length > 1 ? this.selectedIndex : 0;
this.selectedIndex = this.items.length - 1 < this.selectedIndex ? 0 : this.selectedIndex;
const index = this.items.length > 1 ? ((this.items.length - 1) === this.selectedIndex ? -1 : this.selectedIndex) : 0;
setTimeout(() => {
this._currentSelectedIndex = index;
this._currentSelectedIndex = this.selectedIndex;
}, 0);
this.getListStyles(-index * this._rationWidth);
this.carouselInit(this.items);
Expand Down

1 comment on commit 193a4d6

@Guoyuanqiang
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

close #312

Please sign in to comment.