andkulikov / Transitions-Everywhere

Set of extra Transitions on top of Jetpack Transitions Library
Apache License 2.0
4.83k stars 486 forks source link

How are concurrent transitions supposed to be handled? #99

Closed ursusursus closed 4 years ago

ursusursus commented 4 years ago

Hi, I just wrote a simple custom Transition, that animates elevation.

However if I run the transition again via TransitionManager.beginDelayedTransition during the previous one already running. I do observe the previous animator still running, i.e. they both are running at the same time. Visually its not a problem since the second transition always seems to overwrite the value set but the previous animator.

But' this for sure can break in some more complex scenario, so I'd best like to cancel the previous transition animators before starting the new.

Is there an api for that? I see there is protected cancel() but I don't see any of its usage.

andkulikov commented 4 years ago

Hey! That is a good question. Yes, there is an api for it. This should work automatically if inside your custom Transition you override method getTransitionProperties(). See the javadoc for it: https://github.com/aosp-mirror/platform_frameworks_support/blob/b9cd83371e928380610719dfbf97c87c58e80916/transition/transition/src/main/java/androidx/transition/Transition.java#L437 I can show this Transition as an example: https://github.com/aosp-mirror/platform_frameworks_support/blob/b9cd83371e928380610719dfbf97c87c58e80916/transition/transition/src/main/java/androidx/transition/ChangeBounds.java#L188 And actually I am noticed I also forgot to override this method is some of my Transitions in library, thank you for opening this issue

ursusursus commented 4 years ago

Works as you describe. Thanks!