Feature Request: Make it possible to specify the animation used for a transition
It would be helpful to be able to specify which animation is used for a transition. Here is an example use case of my app. I have a tab view listing the soccer matches of the next soccer world championship. So the list looks like this:
- Match 1
- Match 2
- Match 3
- Match 4 ...
Each match list entry is linked to a detail page for that match. So the link structure is like this:
- Match 1 -> Detail View Match 1
- Match 2 -> Detail View Match 2
- Match 3 -> Detail View Match 3
- Match 4 -> Detail View Match 4 ..
All pretty normal. To enable a faster navigation the detail views are working like a carousel (I can not use a carousel there because of performance issues, it would have to load all details of all matches at once). Thus it is possible to navigate from a match detail view directly to the detail view of the next match or to the detail view of the previous match without having to return to the list main view. So the link structure in the detail view for match 2 looks like this
Detail View Match 2 -> Detail View Match 1 Detail View Match 2 -> Detail View Match 3 Detail View Match 2 Back Button -> List View
The use case now is as follows:
- The user chooes in the list match 2. -> The app changes to Detail View Match 2.
- The user changes directly from Detail View Match 2 to Detail View Match 1.
Now it is necessary to tell Ionic to use a left to right transition because the user is logically going backwards in the list to the previous match. If Ionic uses the standard right to left transition this is irritating for the user in this situation. It is like a carousel using a right to left transition for going backwards.
I have the navigation working as described above apart from the transition direction. For the navigation I am using $location.path(url).replace();
I am now also in search for a way to set the direction of an animation when going to a specific state. Is there any progress on this?
I'm actively working on this feature.
Awesome, thanks so much @ajoslin! Any chance at all it might be ready in the next couple of days? I'm nearing the deadline for a project on Friday and it would be great to make use of this in this project.
:beers: @ajoslin
Join the list here for more info soon: https://groups.google.com/forum/#!forum/ionic-vips
@CoenWarmer won't be ready by Friday, sorry.
@ajoslin No worries, I'll find another way. Thanks again!
Also just applied for a membership :+1:
Applied for membership as well.
Sorry , my Android tablet has some problems with the page.
I stopped work on this feature this past week to instead focus on end-to-end testing of Ionic. Will resume work soon.
:+1:
+1 :)
Note that #1506 was closed as a subset of this.
It seems that this feature for specifying the animation transition was prematurely added to ionic code. Here's a snippet from ionic-angular.js version beta.1 :
getRenderer: function(navViewElement, navViewAttrs, navViewScope) {
var service = this;
var registerData;
var doAnimation;
// climb up the DOM and see which animation classname to use, if any
var animationClass = angular.isDefined(navViewScope.$nextAnimation) ?
navViewScope.$nextAnimation :
getParentAnimationClass(navViewElement[0]);
navViewScope.$nextAnimation = undefined;
function getParentAnimationClass(el) {
......more code.....
Notice, that the line var animationClass = ... first checks if a $scope.$nextAnimation is defined, and if it is then it uses that for animationClass, thus making it possible to control animations via code. But the line navViewScope.$nextAnimation = undefined; resets the scope's $nextAnimation variable to undefined, which means that you have to re-assign the value to $nextAnimation everytime after a transition, this is why a little while ago, I opened #1148.
For me, removing the line navViewScope.$nextAnimation = undefined; has made everything work.
It seems that this premature feature has been removed since, and after beta.1, the code above has been changed to
getRenderer: function(navViewElement, navViewAttrs, navViewScope) {
var service = this;
var registerData;
var doAnimation;
// climb up the DOM and see which animation classname to use, if any
var animationClass = getParentAnimationClass(navViewElement[0]);
function getParentAnimationClass(el) {
...more code...
So those who want a quick fix to the problem and don't mind meddling with the source code (probably not recommended) may go ahead and change
var animationClass = getParentAnimationClass(navViewElement[0]);
to
var animationClass = angular.isDefined(navViewScope.$nextAnimation) ?
navViewScope.$nextAnimation :
getParentAnimationClass(navViewElement[0]);
and see if it works for them (is working fine for me). And to the developers working on this (@ajoslin, I think), the fix to this issue might be easier than you were thinking!
As mentioned by @jbavari in ticket #1519, it would be helpful to be able to modify specific parts of existing animations as well.
As noted first by user seanhill and instructed by mhartington on the ionic forums:
http://forum.ionicframework.com/t/side-menu-navicon-fade-in/4912
From his issue: "On the sidemenu starter app, if you click one of the playlist's, the app slides left to show the playlist view, when you click back however, the back button slides away sexy, but on top of the navicon.
Is there a way that navicon button could potentially "fade in" after the back button has slide away?
Thanks"
@ajoslin Just curious, where does this stand? Is there a codepen for this?
Hi ! Any news about it ?
thks
+1
+1