David Haddad
David Haddad

Reputation: 3946

Ionic3 swipeBack not working across app

I have this in my app.module.ts @NGModule imports

    BrowserModule,
IonicModule.forRoot(
  MyApp, 
  {
    //backButtonText: '',
    swipeBackEnabled: true,
    statusbarPadding: false,
  }
),

And running this in my component where I expect swipeback to work results in a 'true'

console.log('swipeback ' + this.navCtrl.swipeBackEnabled);

However neither in the browser nor in the xCode simulator nor in the ios device is the swipeback functionality working.

In terms of the possibility of the swipeBackEnabled value being overridden somewhere else in the app a project-wide search results in 0 other occurrences of the term swipeBackEnabled so it's unlikely that value is being overwritten.

Another way I've tried to debug this is by logging the following:

console.log('swipeBackEnabled ' + this.navCtrl.swipeBackEnabled);
console.log('canGoBack ' + this.navCtrl.canGoBack());
console.log('canSwipeBack ' + this.navCtrl.canSwipeBack());

This is results in true, false, false.

So canGoBack() is resulting in false even though the nav stack has a previous page and the back button is showing and returns the user to a previous page if clicked.

canSwipeBack() according to the ionic NavController documentation only returns true if swipeBackEnabled is true and canGoBack is true and since they're true/false nor true/true it understandable returns false...

Upvotes: 1

Views: 351

Answers (1)

Sampath
Sampath

Reputation: 65978

You need to enable it like this:

ionicModule.forRoot(MyApp, { swipeBackEnabled: true })

Upvotes: 1

Related Questions