Hi guys, I am using Navigator with Custom Transition. router.push() working with Custom Transition but when navigate back, transition is not showing. A page is directly hiding. I am using below code:
As you can see, the ThirdPage tag is closed on the same line, so the following Transition does not belong to it. Fixing that will go a long way.
When working with custom transitions, it’s important to describe all possible directions that your pages are allowed to travel. Say, if it was possible to go directly from FirstPage to ThirdPage, you would want to describe that as well. For a more sophisticated example on transitions, see this.
And here’s your fixed MainView.ux:
<App>
<Router ux:Name="router" />
<Navigator DefaultPath="first" Transition="None" >
<FirstPage ux:Template="first" router="router">
<!-- describes what FirstPage does when we navigate from it to SecondPage -->
<Transition To="second">
<Move Y="-1" Duration="0.5" RelativeTo="ParentSize" Easing="SinusoidalInOut" />
</Transition>
</FirstPage>
<SecondPage ux:Template="second" router="router">
<!-- describes what SecondPage does when we navigate to it from FirstPage -->
<Transition From="first">
<Move Y="1" Duration="0.5" RelativeTo="ParentSize" Easing="SinusoidalInOut" />
</Transition>
<!-- describes what SecondPage does when we navigate from it to ThirdPage -->
<Transition To="third">
<Move X="-1" Duration="0.5" RelativeTo="ParentSize" Easing="SinusoidalInOut" />
</Transition>
</SecondPage>
<ThirdPage ux:Template="third" router="router">
<!-- describes what ThirdPage does when we navigate to it from SecondPage -->
<Transition From="second">
<Move X="1" Duration="0.5" RelativeTo="ParentSize" Easing="SinusoidalInOut" />
</Transition>
</ThirdPage>
</Navigator>
</App>
Thanks Uldis.
I think Dhvl Golakiya is having the same issue as I’m having.
The issue is the following:
when we navigate to the second page, first page should say where it was, it should not move up as in your example. And second page should cover it by sliding from the bottom.
Also when we go back from the second page to the first page, second page should slide down, and reveal first page. First page should not move at all, it should be static.
It’s like you’re having stack of cards, and put new card on top by sliding it from the bottom but old card stays on it’s place.
I’ve simplified example above to 2 pages only, and when I go back to the first page from the second page, no animation happens. But I’ve defined a transition for the second page for such case and disabled transition for the first page so it says where it was. What should be done differently to get second page animated when we go back to the first page?
<App>
<Router ux:Name="router" />
<Navigator DefaultPath="first" Transition="None" >
<FirstPage ux:Template="first" router="router">
<!-- describes what FirstPage does when we navigate from it to SecondPage -->
<Transition To="second">
</Transition>
<!-- describes what FirstPage does when we navigate to it from the Second Page -->
<Transition From="second">
</Transition>
</FirstPage>
<SecondPage ux:Template="second" router="router">
<!-- describes what SecondPage does when we navigate to it from FirstPage -->
<Transition From="first">
<Move Y="1" Duration="0.5" RelativeTo="ParentSize" Easing="SinusoidalInOut" />
</Transition>
<!-- describes what SecondPage does when we navigate from it to FirstPage -->
<Transition To="first">
<Move Y="1" Duration="0.5" RelativeTo="ParentSize" Easing="SinusoidalInOut" />
</Transition>
</SecondPage>
</Navigator>
</App>
Ok after reading Slack discussion on this issue and reading code in fuse-examples repo provided above I found solution for 2 page animations. Animation works exactly as required.
I’ve added GotoState="Unchanged" to the <Navigator> and added ZOffset=0 to the first page and ZOffset=1 to the second page.
So when we go to the second page, state is not changing, I wonder if this can cause some problems I’m not aware of.
<App>
<Router ux:Name="router" />
<Navigator DefaultPath="first" Transition="None" GotoState="Unchanged">
<FirstPage ux:Template="first" router="router" Opacity="0.5" ZOffset="0">
<!-- describes what FirstPage does when we navigate from it to SecondPage -->
<Transition To="second">
</Transition>
<!-- describes what FirstPage does when we navigate to it from the Second Page -->
<Transition From="second">
</Transition>
</FirstPage>
<SecondPage ux:Template="second" router="router" ZOffset="1">
<!-- describes what SecondPage does when we navigate to it from FirstPage -->
<Transition From="first">
<Move Y="1" Duration="0.5" RelativeTo="ParentSize" Easing="SinusoidalInOut" />
</Transition>
<!-- describes what SecondPage does when we navigate from it to FirstPage -->
<Transition To="first">
<Move Y="1" Duration="0.5" RelativeTo="ParentSize" Easing="SinusoidalInOut" />
</Transition>
</SecondPage>
</Navigator>
</App>
@poul: yes, the fact that the first page is immediately brought to front upon going back missed my attention.
Your solution is perfect, and there are no other implications to using GotoState="Unchanged"; in fact, that’s exactly what should be used in this case. Just be aware that this is a setting on the Navigator, so all pages (if there are more than 2) should have their ZOffset set correctly.
I have lots of pages and they can be stacked in arbitrary order. So hardcoding ZOffset is not an option. I wonder if there is a way to change stage of the page programmatically or via UX Action. I’ve searched and tried different actions like <BringToFront>, <Toggle> but looks like they do not change the sate of the <Page>
Thanks for hint Uldis, I’ve tried that, in some cases it helped me to move further but still not able to solve the end goal.
The end result it shown here: https://www.youtube.com/watch?v=NvseD-q3obQ, it was made via <Each>, <AddingAnimation>, <RemovingAnimation> and it works perfectly well and easy to understand and implement. The code is below. So I expected to achieve the same result via <Navigator> but looks like it’s not that easy, as transitions rely on position of the page in the <Navigator> hierarchy, is this page below other page in the list of pages in <Navigator>/<PageControl> or not, and based on that some decisions are made.
However I wanted <Navigator> to behave the same as my example with <Each> I don’t want to care about position of the page inside navigator, is it on top or below, etc. what I want is the same behavior as with <AddingAnimation> and <RemovingAnimation> but with <Transition>. <EnteringAnimation> and <ExitingAnimation> do not allow me to achieve the same effect.
Now I’m thinking on developing my own navigator component with separate service for managing history and stack of pages to implement what I want. I guess it will eat a lot more memory as I’m losing all that reuse/release stuff which is provided by Navigator and alike components.