Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Disabling Animation on NavController#pop via options argument #20586

Closed
TLBSoftware opened this issue Feb 21, 2020 · 4 comments
Closed
Labels

Comments

@TLBSoftware
Copy link

Feature Request

Adding the ability to disable NavController#pop via an options object, this was allowed previously in Ionic v3 but is missing in Ionic v4. Here is a very elaborate analysis of this issue that I have posted on your alls forums with links to the source code. Post Follows

Looks like in the new Ionic v4 the options for disabling animation when using

this.navController.pop()

has unfortunately been removed. However in the source code of the StackController in its implementation of pop which is called via NavControllers pop the framework will eventually use navigateBackward and will pass in the view.savedExtras which should allow someone to disable this pop animation. However these RouteViews are created via this controller and are not given an option to be created with these savedExtras

AND unfortunately I am unable to directly inject the StackController into my class to perform this logic myself. Does anyone have a solution here to perform this? I am unable to directly use navigateBackward because in edge cases another view is navigated to from this page and added to the history and I don't want to go back in the history but back in the stack.

Thanks.

Ionic version:
[x] 4.x

Describe the Feature Request
Add pop options to the NavController like in Ionic v3 so we can disable animation on only a single pop and not via the whole app

Describe Preferred Solution
being able to pass in options to NavController.pop to modify the animations just like in navigateBackward(which is eventually called via the pop method)

Related Code
Ionic v3 link above has the feature request code

@ionitron-bot ionitron-bot bot added the triage label Feb 21, 2020
@liamdebeasi
Copy link
Member

liamdebeasi commented Feb 21, 2020

Thanks for the feature request. The stack does not manage running the animations, so I do not think it would make sense for the pop method to provide animation-related options.

If you need to use pop, you can temporarily disable animation on the current router outlet:

import { NavController, IonRouterOutlet } from '@ionic/angular';

...

goBack() {
  this.routerOutlet.nativeEl.animated = false;
  this.navCtrl.pop();
}

ionViewDidLeave() {
  this.routerOutlet.nativeEl.animated = true;
}

Ideally, you would be able to use navigateBack where you can manage the animation directly, but it does not sound like your use case allows for this. Does the solution I provided work for your use case?

@liamdebeasi liamdebeasi added the needs: reply the issue needs a response from the user label Feb 21, 2020
@ionitron-bot ionitron-bot bot removed the triage label Feb 21, 2020
@TLBSoftware
Copy link
Author

@liamdebeasi Yes this does work thank you. I however had to use this.routerOutlet.animated = false since typescript will not compile with usages of the private variable nativeEl

@ionitron-bot ionitron-bot bot added triage and removed needs: reply the issue needs a response from the user labels Feb 21, 2020
@liamdebeasi
Copy link
Member

Ah sorry, I forgot nativeEl is public only on v5. I am going to close this as the issue appears to be resolved. Thanks!

@ionitron-bot
Copy link

ionitron-bot bot commented Mar 22, 2020

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Mar 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants