MOBILE-3320 tabs: Only slide to tab if not visible

main
Dani Palou 2021-05-05 11:22:35 +02:00
parent 9770072b44
commit f7e531c3d0
1 changed files with 6 additions and 1 deletions

View File

@ -545,7 +545,12 @@ export class CoreTabsBaseComponent<T extends CoreTabBase> implements OnInit, Aft
}
if (this.selected) {
await this.slides!.slideTo(index);
// Check if we need to slide to the tab because it's not visible.
const firstVisibleTab = await this.slides!.getActiveIndex();
const lastVisibleTab = firstVisibleTab + this.slidesOpts.slidesPerView - 1;
if (index < firstVisibleTab || index > lastVisibleTab) {
await this.slides!.slideTo(index, 0, true);
}
}
const ok = await this.loadTab(tabToSelect);