feat(slides): add option for paginationBulletRender

Closes #10002
This commit is contained in:
Mike Hartington
2017-01-13 10:20:56 -05:00
committed by Adam Bradley
parent 14839b66b7
commit 21667c61ac
4 changed files with 14 additions and 3 deletions

View File

@@ -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`.

View File

@@ -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') {
@@ -91,4 +95,3 @@ export function updatePaginationClasses(s: Slides) {
});
}
}

View File

@@ -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({

View File

@@ -5,7 +5,6 @@
(ionSlideDrag)="onSlideDrag($event)"
pager="true"
effect="slide"
paginationType="progress"
slidesPerView="2"
spaceBetween="40">