Skip to content

Commit

Permalink
feat(slides): add option for paginationBulletRender
Browse files Browse the repository at this point in the history
Closes #10002
  • Loading branch information
mhartington authored and adamdbradley committed Jan 13, 2017
1 parent 14839b6 commit 21667c6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/components/slides/slides.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,10 @@ export class Slides extends Ion {
}
private _paginationType = 'bullets';


/** @private */
paginationBulletRender: (index?: number, cssClass?: string) => void = null;

/**
* @input {boolean} Enable, if you want to use "parallaxed" elements inside of
* slider. Default: `false`.
Expand Down
7 changes: 5 additions & 2 deletions src/components/slides/swiper/swiper-pagination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ export function updatePagination(s: Slides) {
if (s.paginationType === 'bullets') {
var numberOfBullets = s.loop ? Math.ceil((s._slides.length - s.loopedSlides * 2) / s.slidesPerGroup) : s._snapGrid.length;
for (var i = 0; i < numberOfBullets; i++) {
paginationHTML += `<button class="${CLS.bullet}" aria-label="Go to slide ${i + 1}" data-slide-index="${i}"></button>`;
if (s.paginationBulletRender) {
paginationHTML += s.paginationBulletRender(i, CLS.bullet);
} else {
paginationHTML += `<button class="${CLS.bullet}" aria-label="Go to slide ${i + 1}" data-slide-index="${i}"></button>`;
}
}

} else if (s.paginationType === 'fraction') {
Expand Down Expand Up @@ -91,4 +95,3 @@ export function updatePaginationClasses(s: Slides) {
});
}
}

5 changes: 5 additions & 0 deletions src/components/slides/test/options/app-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ export class E2EPage {
console.log(`onSlideDrag: ${s}`);
}

ngAfterViewInit() {
this.slider.paginationBulletRender = (index: number, className: string) => {
return `<span class="${className}">${index + 1}</span>`;
};
}
}

@Component({
Expand Down
1 change: 0 additions & 1 deletion src/components/slides/test/options/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
(ionSlideDrag)="onSlideDrag($event)"
pager="true"
effect="slide"
paginationType="progress"
slidesPerView="2"
spaceBetween="40">

Expand Down

0 comments on commit 21667c6

Please sign in to comment.