navPop if swiped right

Is there a finished module already if i swipe right or left that it performs a navPop ?
Or do i have to programm it by myself ? :grin:

Like this quick example:

swipeEvent($e) {

       if ($e.deltaX <= 130) {
            document.getElementById("backbutton").click();
        };
}

<div id="backbutton" (swipe)='swipeEvent($event)' ion-button navPop>

Thanks for any answers.

Does noone has an answer ? :disappointed_relieved:

Can’t you just use the pop() method of the NavController?

this.navCtrl.pop();

navPop works already as mentoined. But what i wanna do is if i swipe to the left that it performs a navPop and i just wanted to know if i have to code it by myself OR if there is a finished module for that already. :slight_smile:

Maybe this can help: [SOLVED] Override swipe to go back gesture (swipeBackEnabled only on one selected page)

Thanks for your answer! I came to this doc.

DOC

I am using this code right now.

ngAfterViewInit() {
	  this.navCtrl.canGoBack();
	  console.log(this.navCtrl.canSwipeBack());
}

What happens i push to this Page and the navPop button appears and works. But it still returns a false for the SwipeBack.
Same with this instance member

canSwipeBack()

Do you know why this could be ? :innocent:

I found this perhaps it is useful for you.

https://docs.angularjs.org/api/ngTouch/directive/ngSwipeRight

I woud add it to the contant tag and call a function inside.

<content ng-swipe-right="myPopFunciton()">

No Idea if this will work!? Try it :slight_smile:

I think the swipe function already works the only problem is that my application thinks that it can’t pop but i clearly can pop.

But thanks anyway.

Ahh ok, your swipe function work and you have tried navCtr.pop() right?

How do you open/call this page?

navCtrl.pop() also works.
Like I said the only problem i have right now is that

this.navCtrl.canSwipeBack();

gives me a false instead of a true and that kinda confuses me because it should give me a true since the page is able to pop.

The rest I can figure out for myself then :grin:.

Ok, but have you opened the actual page with navCtrl.push() or this navCtr.setRoot()

Im pushing to the page like that.

TS

export class MyClass {
goToPopPage: any;
}

constructor(){
this.goToPopPage = PopPage;
}

HTML

[navPush]="goToPopPage"

Could that be the problem ?

I’m a beginner in ionic and angular and i never used [navPush]

I normally use

HTML

(click)="goToMyPage()"

TS

funciton goToMyPage(){
 this.navCtrl.push(PopPage) // import PopPage or
 this.navCtrl.push("PopPage") // lazy loading
}

Yea i don’t need an extra method for it so I sticked to this code i wrote. Ill try it out with a method and post my results.

Still gives me a false :sweat:. I gues ill have to write a code for the function by myself if that won’t work.