TL;DR? How does one get custom page transitions to work in Ionic 5?
Long version:
I am having an issue using the new Animations in Ionic 5 to create custom page transitions.
My app is a Mobile Point of Sale that runs on a specific android device - not available for the mass public to be run on multiple types of devices. Due to the size/complexity of the app and the specifications of the device it can be laggy at times. To counter this, we implemented custom animations to create a perceived performance. However thanks to the latest version of Ionic, the overall performance has improved for the app - so many thanks to the Ionic Team. We still however need the custom animations in the app.
I have been able to get the modal animations to work thanks to help received in a previous post that I opened and closed. I have tried to use that same logic in my page animations but am not having much luck.
What I am trying to do is implement a page transition similar to that of iOS, whereby the current page will slide out and the new page will slide in. I have had some luck on this in that it applies the animation correctly. The animation however plays both the leave and enter animation at the same time which causes a ‘morphing’ of the 2 sets of markup on the 2 pages. So everything goes funky.
I have tried to implement it using this logic, but have had no success .
I have created a demo project on github to demonstrate this issue. If somebody could perhaps help me with this it would be most appreciated. There is a README.me describing how to re-create the issue.
This is a v5 project, using Angular 8 and Capacitor.
This is what I have been able to get to work. It is animating the pages, however it is animating them in the wrong order (it is showing the page to add on-top and then animating it out. Then once the animation is complete it just magically shows the correct page).
Additionally, it seems like it is morphing the 2 pages in the animation so the content is being displayed incorrectly on the view.
Please note, the error being displayed at the end has to do with a seperate API call being made, not the animation itself.
So I’m planning a blog post on this to dive into more details, but you can see a simple example here
What tripped me up was that when are navigating back, the enter/leaving el are now different and need to be accounted for in that animation. This is noted in my demo.
is there any way to have different animations for different pages? Route Transitions in Angular do exactly what I need, but ion-router-outlet does not work with it.
Hi yes, and your example worked, but what if I want to specify different animations depending on the page I am loading. Like Page 1 slides in from left, Page 2 slides from bottom and etc.
Edit: I just saw your reply to my thread. I will wait until Ionic 5.2.
First of all thank you very much for your contribution. Can I also ask how to use different animation for each page? We initiate the animation in each page module?
I had a look at your page transition example and it works well if I run it. But when I try do the same in my own application, setting the navAnimations option doesn’t seem to have the same effect - it still uses the default animations.
Yes its possible if you open fancyAnimation class you can check element tag to find out which element is animating so you can put check on tagName to give particular animation to particular page.