Search code examples
typescriptionic-frameworkionic2gestureionic3

Ionic swipe gesture not working on phone


I try to do a swipe gesture to switch between tabs. I want the gesture will work on all over the screen. I catch the swipe movement in

<ion-content (swipe)="swipeEvent($event)">

And the swipeEvent funtion is

swipeEvent(e) {
  if(e.direction == '2'){
     this.navCtrl.parent.select(2);
  }
  else if(e.direction == '4'){
     this.navCtrl.parent.select(0);
  }
}

It works fine in browser. But when I build it in a phone the gesture has no effect. Is there any alternative solution?


Solution

  • Just solved it by adding a div with 100% height and width.

    <ion-content padding>
      <div (swipe)="swipeEvent($event)" style="position: absolute;top:0;left:0;height:100%;width:100%;">
        <ion-item>
    
        </ion-item>
      </div>
    </ion-content>