I think Crossfade should not clip graphicsLayer.
When crossfade is animating, it uses:
keys.mapTo(items) { key ->
CrossfadeAnimationItem(key) {
val alpha by transition.animateFloat(
transitionSpec = { animationSpec }
) { if (it == key) 1f else 0f }
// NOTICE
Box(Modifier.alpha(alpha = alpha)) {
content(key)
}
}
}
And if it is not animating, it uses:
Box(modifier) {
items.fastForEach {
key(it.key) {
it.content()
}
}
}
The problem is,
Modifier.alpha()
is an alias of
graphicsLayer(alpha = alpha, clip = true)
,
If you are holding a Button, Card or anything with shadow, Crossfade will clip the shadow when animation starts, and resume when animation finishes, that will be very unnatural.
And I wonder the reason that
Modifier.alpha()
sets
clip
property to true, is that really necessary?