# compose


02/06/2022, 1:24 AM
with navigation animations via Accompanist library, does anyone know if there's a way to define your animation(s) at the time of calling
? my use case is that I have a dynamic screen which can be accessed by either tapping through the UI, and it can be nested many levels deep, and my animation for sliding in and out works great there, but this dynamic screen can also be accessed via the hamburger menu, and when it's accessed from there, I want to clear the backstack (which is the easy part) but I also want the transition to be different, because sliding in feels and looks totally wrong there is this possible? or will I need to create entirely different routes and
composable(transition = )
declarations and just use different routes to display the same screen but with alternate transition animations?

Ian Lake

02/06/2022, 1:51 AM
Your transition lambdas can capture whatever other state you want (i.e., a
boolean you set only when navigating from your drawer) if the information of where you are going to and whether it is a pop isn't enough information
I'm having a hard time thinking of a case where the from/to information you get as part of the
and whether it is a pop or not isn't enough information though? I guess if you are on the screen deep in your hierarchy right before this also accessible via the drawer screen and instead of clicking on the button to go to that screen, the user clicks on the drawer icon?
The other option, of course, is an optional argument you only set as part of navigating in one of your two cases - since you get the
as the
, you could just check for the existence of that argument in your transition lambdas to know which to run


02/06/2022, 2:30 AM
to expand on the use case and explain why to/from isn't enough info: imagine a route that looks something like
you could be 3 levels deep in the UX flow and click something which would take you to
.. and that animation should slide in and out and your backstack remains intact however, you could also decide to open the nav drawer and click the "Cat" menu item there which would navigate you to the same
route, but this time we want to clear the back stack and maybe do a quick crossfade transition, not a sliding one
in saying all of that, your third reply works! I totally forgot I had access to
from inside the transition lambda, so I can simply check a parameter added to the route