Skip to content

ion-tab-button should also listen for "touchstart" #16911

Closed

Description

@bitroost

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

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

  1. changed the title [-]ion-tab-button should also listen for "touchend"[/-] [+]ion-tab-button should also listen for "touchstart"[/+] on Dec 29, 2018
  2. added
    type: feature request
    and removed on Jan 2, 2019
  3. added a commit that references this issue on Jan 18, 2019
    5cb7f68
  4. ionitron-bot commented on Feb 17, 2019

    @ionitron-bot

    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.

  5. locked and limited conversation to collaborators on Feb 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: feature request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions