ionic-framework icon indicating copy to clipboard operation
ionic-framework copied to clipboard

Feature Request: Make it possible to specify the animation used for a transition

Open ch-weiss opened this issue 12 years ago • 44 comments

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:

  1. Match 1
  2. Match 2
  3. Match 3
  4. Match 4 ...

Each match list entry is linked to a detail page for that match. So the link structure is like this:

  1. Match 1 -> Detail View Match 1
  2. Match 2 -> Detail View Match 2
  3. Match 3 -> Detail View Match 3
  4. 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:

  1. The user chooes in the list match 2. -> The app changes to Detail View Match 2.
  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();

ch-weiss avatar May 06 '14 16:05 ch-weiss

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?

CoenWarmer avatar May 12 '14 17:05 CoenWarmer

I'm actively working on this feature.

ajoslin avatar May 12 '14 17:05 ajoslin

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.

CoenWarmer avatar May 12 '14 17:05 CoenWarmer

:beers: @ajoslin

dbaq avatar May 12 '14 17:05 dbaq

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 avatar May 12 '14 18:05 ajoslin

@ajoslin No worries, I'll find another way. Thanks again!

CoenWarmer avatar May 12 '14 18:05 CoenWarmer

Also just applied for a membership :+1:

CoenWarmer avatar May 12 '14 18:05 CoenWarmer

Applied for membership as well.

ch-weiss avatar May 12 '14 23:05 ch-weiss

Sorry , my Android tablet has some problems with the page.

ch-weiss avatar May 12 '14 23:05 ch-weiss

I stopped work on this feature this past week to instead focus on end-to-end testing of Ionic. Will resume work soon.

ajoslin avatar May 21 '14 13:05 ajoslin

:+1:

ch-weiss avatar May 23 '14 13:05 ch-weiss

+1 :)

JeanCarriere avatar May 23 '14 14:05 JeanCarriere

Note that #1506 was closed as a subset of this.

perrygovier avatar May 27 '14 17:05 perrygovier

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!

peey avatar May 28 '14 06:05 peey

As mentioned by @jbavari in ticket #1519, it would be helpful to be able to modify specific parts of existing animations as well.

perrygovier avatar May 29 '14 15:05 perrygovier

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"

jbavari avatar May 29 '14 15:05 jbavari

@ajoslin Just curious, where does this stand? Is there a codepen for this?

cggaurav avatar Aug 26 '14 21:08 cggaurav

Hi ! Any news about it ?

thks

slegouffe avatar Sep 28 '14 17:09 slegouffe

+1

joeandrews avatar Sep 29 '14 17:09 joeandrews

+1

bra1n avatar Oct 08 '14 22:10 bra1n