Skip to content

Commit

Permalink
fix(carousel): fix multilist carousel order (#5193)
Browse files Browse the repository at this point in the history
  • Loading branch information
musienkoyuriy authored and Domainv committed May 13, 2019
1 parent 82dca85 commit 1f883cb
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/carousel/carousel.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ export class CarouselComponent implements AfterViewInit, OnDestroy {
}

this._slidesWithIndexes.forEach((slide: SlideWithIndex) => slide.item.active = true);
this.makeSlidesConsistent();
this.makeSlidesConsistent(this._slidesWithIndexes);
} else {
this.selectRangeByNestedIndex(startIndex);
}
Expand Down Expand Up @@ -399,7 +399,7 @@ export class CarouselComponent implements AfterViewInit, OnDestroy {
: index + 1;

this._slidesWithIndexes = this.mapSlidesAndIndexes().slice(startIndex, endIndex);
this.makeSlidesConsistent();
this.makeSlidesConsistent(this._slidesWithIndexes);

this._slidesWithIndexes.forEach((slide: SlideWithIndex) => slide.item.active = true);
}
Expand Down Expand Up @@ -482,6 +482,12 @@ export class CarouselComponent implements AfterViewInit, OnDestroy {
this._slides.get(indexToHide).active = false;
this._slides.get(indexToShow).active = true;

const slidesToReorder = this.mapSlidesAndIndexes().filter(
(slide: SlideWithIndex) => slide.item.active
);

this.makeSlidesConsistent(slidesToReorder);

this.slideRangeChange.emit(this.getVisibleIndexes());
} else {
let displayedIndex: number;
Expand Down Expand Up @@ -512,22 +518,20 @@ export class CarouselComponent implements AfterViewInit, OnDestroy {
}, ...this._slidesWithIndexes];
}


this.makeSlidesConsistent();
this.hideSlides();

this._slidesWithIndexes.forEach(slide => slide.item.active = true);

this.makeSlidesConsistent(this._slidesWithIndexes);

this.slideRangeChange.emit(
this._slidesWithIndexes.map((slide: SlideWithIndex) => slide.index)
);
}
}

private makeSlidesConsistent(): void {
this._slidesWithIndexes.forEach((slide: SlideWithIndex, index: number) => {
slide.item.order = index;
});
private makeSlidesConsistent = (slides: SlideWithIndex[]): void => {
slides.forEach((slide: SlideWithIndex, index: number) => slide.item.order = index);
}

private moveMultilist(direction: Direction): void {
Expand Down

0 comments on commit 1f883cb

Please sign in to comment.