Hi everyone I have a question about animation bet...
# compose-android
y
Hi everyone I have a question about animation between composable screens. When I set the animation to just 700 ms, if the user clicks very fast, a problem occurs in my case. What is the best way to set animations for between screens?
g
Are you using
androidx.navigation
? If yes, are you talking about the weird artifacts you get when you call
navigate()
while the animation of the previous
navigate()
call is still ongoing? If yes, I'd like to know how to work around that issue. A faster animation helps, but I'm considering adding an invisible overlay to intercept touches while there are ongoing animations. Not ideal, but with reasonably fast transitions it shouldn't be too much of a problem.
i
What is the problem you're trying to solve? Setting the animation? A visual artifact when interrupting? Or not allowing navigate calls when there's an animation running?
The last problem of avoiding clicks while animating between screens already has a method to do exactly that, something we've discussed previously: https://kotlinlang.slack.com/archives/CJLTWPH7S/p1733050890150819?thread_ts=1733036395.744259&cid=CJLTWPH7S
g
Yes,
dropUnless*
would solve the problem, but I'd rahter not rely on it. It is both easy to forget and hard to notice that it is missing. In particular, my problem is that entering screens are interactive, so if the user manages to press something to navigate to some other screen while a screen is already entering, the animation glitches. I wrote a
Modifier
for the
NavHost
earlier today that consumes touch events while there are ongoing transitions. It seems to work fine so far, but I barely tested it.
y
Thanks in my case
dropUnlessResumed
block helped me.