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

ion-nav-bar inside ion-nav-view to apply the animation also on the nav-bar

Open dbaq opened this issue 12 years ago • 22 comments

Hi guys,

I was wondering if there is a way to include the ion-nav-bar inside the ion-nav-view, with that, developers will be able to apply the animation on the nav-bar also. We can see this kind of animations between transitions on several well known apps (twitter for android v.5.7.0, facebook messenger for android, etc..). The nav-bar is always included inside the transition, not only the content.

I made a codepen with my attempt to do it: http://codepen.io/anon/pen/ogJBa

And this one http://codepen.io/anon/pen/JGgIh to show how weird it could be if the nav-bar on a view is not displayed.

thanks for your answer :smile: :beers:

dbaq avatar Apr 30 '14 02:04 dbaq

Did you try adding an animation class to the navbar itself?

http://ionicframework.com/docs/api/directive/ionNavBar/ recommends 'nav-title-slide-ios7'

ajoslin avatar Apr 30 '14 17:04 ajoslin

I thought the animation in the nav bar was only for the title and the buttons, not the bar itself. I have to try this. But I am not sure about the render of the animation because there is a scale notion.

It works if I am using a basic header instead of ion-nav-bar inside the ion-view, cf that codepen: http://codepen.io/anon/pen/zGDwC

dbaq avatar Apr 30 '14 18:04 dbaq

I see what you mean ... you want to animate the whole navbar every view change?

ajoslin avatar Apr 30 '14 19:04 ajoslin

basically, I want to animate the whole view (header, footer, content). The animation that I reproduced here (http://codepen.io/anon/pen/zGDwC for the demo) is used in a lot of apps. I know that my request looks like I am picky but I really think that is a must have if we want to have a native look n feel.

your current implement is very iOS centric (I just checked on my coworker's iPhone 5 - twitter app).

what do you think?

dbaq avatar Apr 30 '14 20:04 dbaq

OK, added one thing to let you do this!

Now you can put an ion-nav-bar inside each individual ion-view:

<script id="view1.html" type="text/ng-template">
  <ion-nav-bar class="bar-positive">
    <ion-nav-back-button>Back</ion-nav-back-button>
  </ion-nav-bar>
  <ion-view title="view1"></ion-view>
</script>

<script id="view2.html" type="text/ng-template">
  <ion-nav-bar class="bar-positive">
    <ion-nav-back-button>Back</ion-nav-back-button>
  </ion-nav-bar>
  <ion-view title="view2"></ion-view>
</script>

Check the docs when the travis build finishes for a full explanation: http://ionicframework.com/docs/nightly/api/directive/ionNavBar

Note that you don't want an animation class on the navbar if you do this.

ajoslin avatar Apr 30 '14 20:04 ajoslin

Please test it out heavily in your app and let me know any problems; this addition is pretty experimental.

ajoslin avatar Apr 30 '14 20:04 ajoslin

Thanks I will try this out by this weekend!

dbaq avatar Apr 30 '14 20:04 dbaq

As far as I've tested, it is working well. Tested on my android device and on the iOS simulator. I don't have any iOS devices here to test.

dbaq avatar May 05 '14 02:05 dbaq

I tested in iOS 7.1 and the functionality it's working well except a withe vertical 1px line between views using <body ng-app="starter" animation="slide-left-right-ios7">

gastonbesada avatar May 05 '14 03:05 gastonbesada

@gastonbesada do you have anymore information? Could you post a plnkr/codepen to reproduce this?

ajoslin avatar May 06 '14 14:05 ajoslin

@gatonbesada bump :-) Any more informatino about this 1px line problem?

ajoslin avatar May 09 '14 13:05 ajoslin

@ajoslin Here is the cp: http://codepen.io/gastonbesada/pen/ctFdD

I rewrite the transition time to help to see it.

Thanks

gastonbesada avatar May 09 '14 13:05 gastonbesada

Oh @ajoslin , I saw, I had the nav-bar inside of nav-view. Now I moved it outside and when the nav-bar is blurred in/out, I see the pane background (white).

gastonbesada avatar May 09 '14 13:05 gastonbesada

Your codepen will work if you take out the nav-title-slide-ios7 attribute. you don't need it anymore, since the parent page will be causing the navbar to animate.

ajoslin avatar May 09 '14 14:05 ajoslin

I removed nav-title-slide-ios7and now I see the 1px vertical line in the nav-bar. http://codepen.io/gastonbesada/pen/ctFdD

gastonbesada avatar May 09 '14 14:05 gastonbesada

Fixed by removing the border rule from the bar. Not sure why it's there - I'll make sure it's not useful and push if so.

ajoslin avatar May 14 '14 14:05 ajoslin

Found the source, fixed.

ajoslin avatar May 14 '14 14:05 ajoslin

I'm having some problems with the ionNavBackButton when I put the ion-nav-bar inside each ion-view.

After some debugging it seems to me that when the ion-nav-bar is placed inside of each individual ion-view, the navigation history is not registered unless there is an ionNavBackButton in the ion-nav-bar. And therefore the back button is hidden until you visit your 2nd view containing a back button.

Here are two codepens to demonstrate:

  1. Here back-buttons are placed in each view: http://codepen.io/ooystein/pen/dlgGH
  2. In this example the back-button in the first view(Home) is removed, and it prevents the back button in the other views from showing up on the first visit: http://codepen.io/ooystein/pen/CLfFj

Is this a bug, or am I using it wrong? The codepen example is probably not good at illustrating the need for this functionality since you probably don't want a back button on pages in the menu anyway. But it demonstrates the problem.

ooystein avatar May 27 '14 22:05 ooystein

Im having the same problem as you @ooystein - did you find any solution?

kaililleby avatar Jun 16 '14 11:06 kaililleby

No. I reverted to using the navbar the standard way.

ooystein avatar Jun 16 '14 23:06 ooystein