Repository navigation
Description
Feature Request
Ionic version:
[x] 4.x
Describe the Feature Request
Currently ion-tab-button only listens for click events https://github.com/ionic-team/ionic/blob/302be5392c56dde27c3175ba637eb0e3dd45af40/core/src/components/tab-button/tab-button.tsx#L65
which doesn't seem to fire during "Inertia scrolling/rubber band scrolling"-animations.
Steps to reproduce problem
$ ionic start myApp tabs --type=angular- fill myApp/src/tab1/tab1.page.html area with dummy-content.
Now, especially on iOS, during the "Inertia scrolling"-animation (https://youtu.be/s-ucKJhRSz8) switching tabs is not possible and makes the app feel unresponsive.
Workaround fix
Listen to the touchstart event:
change myApp/src/tabs/tabs.page.ts to
import { Component, ViewChild, ViewChildren, ElementRef } from '@angular/core';
import { IonTabs, IonTabButton } from '@ionic/angular';
@Component({
selector: 'app-tabs',
templateUrl: 'tabs.page.html',
styleUrls: ['tabs.page.scss']
})
export class TabsPage {
@ViewChild(IonTabs) tabs: IonTabs;
@ViewChildren(IonTabButton, {read: ElementRef}) tabbuttonsEl: any;
@ViewChildren(IonTabButton) tabbuttons: any;
constructor() { }
onTouch(index) {
this.tabs.select(this.tabbuttons.toArray()[index].tab);
}
ngAfterViewInit() {
this.tabbuttonsEl.forEach((tabbuttonEl, index) => {
tabbuttonEl.onTouch = this.onTouch.bind(this, index);
tabbuttonEl.nativeElement.addEventListener(
'touchstart', tabbuttonEl.onTouch, { passive: true }
);
});
}
ngOnDestroy() {
this.tabbuttonsEl.forEach((tabbuttonEl) => {
tabbuttonEl.nativeElement.removeEventListener('touchstart', tabbuttonEl.onTouch);
});
}
}
Describe Preferred Solution
The workaround just proofs that listening to touchstart fixes the problem but this needs to be adressed at the component-level.
Additional Context
I also think there should be possibility to set -webkit-overflow-scrolling to auto for the ion-content component to turn off "Inertia scrolling/rubber band scrolling" if needed. Just a var at https://github.com/ionic-team/ionic/blob/302be5392c56dde27c3175ba637eb0e3dd45af40/core/src/components/content/content.scss#L74
Activity
[-]ion-tab-button should also listen for "touchend"[/-][+]ion-tab-button should also listen for "touchstart"[/+]fix(content): tap-click deadlock (#17170)
ionitron-bot commentedon Feb 17, 2019
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.