Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ To use lazy loading, pass the carousel an array of images, as shown in the examp
| autoplayInterval | number | 5000 | The interval between scrolling the carousel. Used together with autoplay. |
| pauseOnHover | boolean | true | Stops autoplay if the cursor is over the carousel area. |
| dots | boolean | false | Carousel progress bar. |
| dotsPerPage | boolean | false | If cellsToShow and cellsToScroll are larger than 1, if dotsPerPage is true it will only show 1 dot per page of cells. So with 9 images and cellsToShow and Scrollset ot 3 it will show only 3 dots |
| margin | number | 10 | Cell spacing. |
| minSwipeDistance | number | 10 | Minimum distance for swipe. |
| transitionDuration | number | 300 | Animation duration. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ export class CarouselComponent implements OnDestroy {
}

get activeDotIndex() {
if (this.dotsPerPage) {
return Math.ceil(this.slideCounter / this.cellsToScroll) % this.dotsArr.length;
}
return this.slideCounter % this.cellLength;
}

Expand All @@ -116,6 +119,7 @@ export class CarouselComponent implements OnDestroy {
@Input() autoplayInterval: number = 5000;
@Input() pauseOnHover: boolean = true;
@Input() dots: boolean = false;
@Input() dotsPerPage: boolean = false;
@Input() borderRadius!: number;
@Input() margin: number = 10;
@Input() objectFit: 'contain' | 'cover' | 'none' = 'cover';
Expand Down Expand Up @@ -237,7 +241,7 @@ export class CarouselComponent implements OnDestroy {
ngAfterViewInit() {
this.initCarousel();
this.cellLength = this.getCellLength();
this.dotsArr = Array(this.cellLength).fill(1);
this.dotsArr = this.dotsPerPage ? Array(Math.ceil(this.cellLength/this.cellsToScroll)).fill(1): Array(this.cellLength).fill(1);
this.ref.detectChanges();
this.carousel.lineUpCells();
this.savedCarouselWidth = this.carouselWidth;
Expand Down
13 changes: 13 additions & 0 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,19 @@ <h3>dots = true</h3>
</carousel>
</div>

<!-- cellsToShow, cellsToScroll, dotsPerPage -->
<div class="demo">
<h3>cellsToShow = 3, cellsToScroll = 3, dotsPerPage = true</h3>
<carousel
[images]="images"
[height]="150"
[cellsToShow]="3"
[cellsToScroll]="3"
[dots]="true"
[dotsPerPage]="true">
</carousel>
</div>

<!-- objectFit -->
<div class="demo">
<h3>objectFit = contain</h3>
Expand Down