Merge pull request #2276 from nguyenphuctien/MOBILE-3284_integration

MOBILE-3284 Accessibility - Page through course page tabs
main
Dani Palou 2020-02-11 10:06:00 +01:00 committed by GitHub
commit cf6d7b0269
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 47 additions and 4 deletions

View File

@ -90,6 +90,7 @@ export class CoreTabsComponent implements OnInit, AfterViewInit, OnChanges, OnDe
protected firstSelectedTab: number; protected firstSelectedTab: number;
protected unregisterBackButtonAction: any; protected unregisterBackButtonAction: any;
protected languageChangedSubscription: Subscription; protected languageChangedSubscription: Subscription;
protected isInTransition = false; // Weather Slides is in transition.
constructor(element: ElementRef, protected content: Content, protected domUtils: CoreDomUtilsProvider, constructor(element: ElementRef, protected content: Content, protected domUtils: CoreDomUtilsProvider,
protected appProvider: CoreAppProvider, private configProvider: CoreConfigProvider, platform: Platform, protected appProvider: CoreAppProvider, private configProvider: CoreConfigProvider, platform: Platform,
@ -328,6 +329,7 @@ export class CoreTabsComponent implements OnInit, AfterViewInit, OnChanges, OnDe
*/ */
slideChanged(): void { slideChanged(): void {
const currentIndex = this.slides.getActiveIndex(); const currentIndex = this.slides.getActiveIndex();
this.isInTransition = false;
if (this.slidesShown >= this.numTabsShown) { if (this.slidesShown >= this.numTabsShown) {
this.showPrevButton = false; this.showPrevButton = false;
this.showNextButton = false; this.showNextButton = false;
@ -407,20 +409,61 @@ export class CoreTabsComponent implements OnInit, AfterViewInit, OnChanges, OnDe
} }
/** /**
* Method that shows the next slide. * Method that shows the next page.
*/ */
slideNext(): void { slideNext(): void {
if (this.showNextButton) { if (this.showNextButton) {
this.slides.slideNext(); // Stop if slides are in transition.
if (this.isInTransition)
return;
if (this.slides.isBeginning()) {
// Slide to the second page.
this.slides.slideTo(this.maxSlides);
} else {
const currentIndex = this.slides.getActiveIndex();
if (typeof currentIndex !== 'undefined') {
const nextSlideIndex = currentIndex + this.maxSlides;
this.isInTransition = true;
if (nextSlideIndex < this.numTabsShown) {
// Slide to the next page.
this.slides.slideTo(nextSlideIndex);
} else {
// Slide to the latest slide.
this.slides.slideTo(this.numTabsShown - 1);
}
}
}
} }
} }
/** /**
* Method that shows the previous slide. * Method that shows the previous page.
*/ */
slidePrev(): void { slidePrev(): void {
if (this.showPrevButton) { if (this.showPrevButton) {
this.slides.slidePrev(); // Stop if slides are in transition.
if (this.isInTransition)
return;
if (this.slides.isEnd()) {
this.slides.slideTo(this.numTabsShown - this.maxSlides * 2);
// Slide to the previous of the latest page.
} else {
const currentIndex = this.slides.getActiveIndex();
if (typeof currentIndex !== 'undefined') {
const prevSlideIndex = currentIndex - this.maxSlides;
this.isInTransition = true;
if (prevSlideIndex >= 0) {
// Slide to the previous page.
this.slides.slideTo(prevSlideIndex);
} else {
// Slide to the first page.
this.slides.slideTo(0);
}
}
}
} }
} }