Search code examples
ionic2vertical-scrollingios10.2

Ionic 2 list avoid accidental click while scrolling


In the following contacts list in iOS 10 device, while doing infinite scrolling angular2+Meteor+Ionic2 app, many times the click event gets fired and the contact detail page gets displayed.

  <ion-content class="contacts-page-content">
    <ion-list>
      <button ion-item *ngFor="let contact of contacts | async" (click)="showContactDetails(contact)" text-wrap class="contacts">
          <ion-avatar item-left>
            <img[src]="contact.picture">
          </ion-avatar>
          <h2 class="contact-name">{{contact.firstName}} {{contact.lastName}}</h2>
          <h4 ion-text color="grayText">{{contact.jobTitle}}</h4>
          <h3 class="contact-supplier" *ngIf="contact.supplierName">{{contact.supplierName}}</h3>
      </button>
    </ion-list>
    <ion-infinite-scroll (ionInfinite)="pullMoreContacts($event)">
           <ion-infinite-scroll-content
          loadingSpinner="bubbles"
          loadingText="Loading more contacts...">
          </ion-infinite-scroll-content>
    </ion-infinite-scroll>   
  </ion-content>

Is there anyway the click while scrolling can be avoided? Any help is greatly appreciated.

Thanks.


Solution

  • Check here for ionic 2 gestures. Try

    (tap)=showContactDetails(contact)

    instead of click.