I think Crossfade should not clip graphicsLayer. W...
# compose
k
I think Crossfade should not clip graphicsLayer. When crossfade is animating, it uses:
Copy code
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:
Copy code
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?
d
You are right, it's not a desirable behavior to clip in
Crossfade
. Could you file a bug on that? @Nader Jawad on the question regarding
Modifier.alpha
clipping by default.
k
n
Whenever a layer has alpha applied to it, an offscreen buffer is created and the composable is drawn into that layer before the alpha is applied and drawn to the display
😄 1
When this happens we size the layer to the bounds of the composable, however whenever content extends beyond the bounds of the layer it gets ommitted from this layer showing the "clipping" behavior you are seeing
😄 1
It is a known issue and the layer sizing should take into account the extended bounds of the shadow itself.
😄 1
I believe if the alpha and shadow are applied on the same layer it would work
😄 1
1