ionic-framework: bug: (angular) gesture partial back
Bug Report
Ionic version:
[x] 4.x
Current behavior: When viewing a Detail view you can swipe back to return to the List view you came from. However if you only drag your finger partially across the screen and return back to the Detail view without removing your finger, the view begins to behave strangely. The List view is now visible. Expected behavior: If you start to swipe right to back out of a view and gesture back to pull the page back into view. The previous page should be hidden
Steps to reproduce:
- From the home view, tap on push me button
- Drag your finger from left to right, stopping in the middle of the screen
- Without removing your finger, drag your finger back to the left which will return you to the “other” page Related code: https://github.com/Kadinvanvalin/ionic-gesture-back
// stack-controller.ts
// I was able to fix locally by adding the else statement.
endBackTransition(shouldComplete: boolean) {
if (shouldComplete) {
this.skipTransition = true;
this.pop(1);
} else {
const leavingView = this.activeView;
const viewsSnapshot = this.views.slice();
if (leavingView) { cleanupAsync(leavingView, this.views, viewsSnapshot, this.location); }
}
}
Other information:
.ion-page-hidden is removed when you start the gesture, but isn’t reapplied at the end of the gesture if you end on the “wrong page” Ionic info:
Ionic:
ionic (Ionic CLI) : 4.3.1 (/Users/kadin/.nvm/versions/node/v11.1.0/lib/node_modules/ionic)
Ionic Framework : @ionic/angular 4.4.2
@angular-devkit/build-angular : 0.13.9
@angular-devkit/schematics : 7.3.9
@angular/cli : 7.3.9
@ionic/angular-toolkit : 1.5.1
System:
NodeJS : v11.1.0 (/Users/kadin/.nvm/versions/node/v11.1.0/bin/node)
npm : 6.9.0
OS : macOS
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 2
- Comments: 16 (6 by maintainers)
Commits related to this issue
- fix(router): fix partial gesture fixes #18462 — committed to ionic-team/ionic-framework by manucorporat 5 years ago
- fix(router): fix partial gesture fixes #18462 — committed to ionic-team/ionic-framework by manucorporat 5 years ago
- fix(router): fix partial gesture fixes #18462 — committed to ionic-team/ionic-framework by manucorporat 5 years ago
- fix(router): fix partial gesture fixes #18462 — committed to ionic-team/ionic-framework by manucorporat 5 years ago
- fix(router): fix partial gesture (#18977) fixes #18462 — committed to ionic-team/ionic-framework by manucorporat 5 years ago
@joshstrange seems overkill…better solution would be to just reapply
.ion-page-hiddenat the end of the gesture as @Kadinvanvalin suggested in the bug report.I can confirm this issue. In my case, I am using the
cordova-plugin-camera-previewplugin on a subpage and have to make the whole content transparent. Everything works fine until I use swipe to go back.The behaviour is very weird:
We are currently migrating our app to Ionic 4 and this branch is not public yet. But if it would help you in reproducing the error, I can try to make it public.
Here is a video: https://streamable.com/tt8p9
EDIT: My temporary solution is to simply disable swipe to go back in the whole application. Ideally I would like to only disable it on some pages, but I couldn’t find any docs for it. Is there a way to do that?
@joshstrange
Your effort deserves to be rewarded 🎖
@dansiemens 🤦♂ Yeah it probably would… Ok, well I’m rushing to ship this app in the next 30min but I will play around with a fix that JUST does that later. Thank you, I somehow missed that reading through everything.
@hiepxanh Ok I’ve got a REALLY gross work around that involves patching @ionic/angular. It’s not pretty but I think it covers all the bases. What I DON’T know is if it breaks anything else. I haven’t scripted it yet but it shouldn’t be hard to script as a hook.
What I’m doing is 2 things.
shouldCompleteis always true. This is needed because if you don’t do this and hold your finger on the screen for the duration of the animation then it will look like you went back but technically you are still on the page you “left” and you have to swipe back a second time.I do not like or advocate something like this normally, ideally we would at a minimum get the functionality I hacked in as an option like
swipeType="instant"that we could put onion-router-outletbut I’m terrible at naming so I’m sure someone else come up a better name. I make no promises that this will work on versions other than@ionic/angular@4.6.0but feel free to try to make similar changes to other versions.The hack
In
./node_modules/@ionic/angular/dist/fesm5.jsadd the following lines at the bottom of the file right above theexport { .....}line. You could instead edit them in the file instead of overwriting them but I found this to be cleaner and more obvious as to what I’m doing.To be fair… It’s not really “monkey patching” as I’m pretty sure that is something you do at runtime but I wasn’t able to figure out a way to do true “monkey patching” but maybe someone smarter can figure it out so we don’t have to edit
node_modules. Also I know my second edit could have been done about 3 different ways but this was the cleanest IMHO and is obviously what I changed (vs just removing theif)Like I said this should be easy enough to script into an after_prepare hook or something like that…
Edit: Well I feel like a moron, ANOTHER fix that requires NO PATCHING is to just set
animated="false"on theion-router-outlet. My patch will keep the animation (just not let you stop it) so I think I’ll still ship with my “hack” but for those who don’t want to hack it I understand. I might see if I can’t just fork @ionic/angular and add adraggableinput to the directive that will be used to do what my hack does. That way everyone could just set it tofalseto avoid this issue.Obviously the best of all worlds would be to fix the actual issue here so we could drag it and cancel it and not have these problems but… well someone smarter is going to have to do that, I’m tapped out.
Edit 2: Ok here is the file to patch it: https://gist.github.com/joshstrange/23546d07c9294671200d3b5f4c85c934 and you just need to add
"prepare": "node scripts/patch-ionic-angular.js",to thescriptssection inpackage.json(update the path to wherever you want to save thepatch-ionic-angular.jsfile