@@ -4,10 +4,10 @@ import androidx.compose.animation.AnimatedContentTransitionScope
44import androidx.compose.animation.ContentTransform
55import androidx.compose.animation.SizeTransform
66import androidx.compose.animation.core.keyframes
7+ import androidx.compose.animation.expandVertically
78import androidx.compose.animation.fadeIn
89import androidx.compose.animation.fadeOut
9- import androidx.compose.animation.slideInVertically
10- import androidx.compose.animation.slideOutVertically
10+ import androidx.compose.animation.shrinkVertically
1111import androidx.compose.animation.togetherWith
1212import androidx.compose.ui.unit.IntSize
1313
@@ -30,12 +30,20 @@ private const val A_QUARTER = 4
3030 * as well as the size transformation.
3131 */
3232fun <T > AnimatedContentTransitionScope<T>.bannerSlideInSlideOutAnimationSpec (): ContentTransform {
33- val enter = fadeIn() + slideInVertically()
34- val exit = fadeOut() + slideOutVertically()
35- return enter togetherWith exit using SizeTransform { initialSize, targetSize ->
36- keyframes {
37- IntSize (width = targetSize.width, height = initialSize.height) at durationMillis / A_QUARTER
38- IntSize (width = targetSize.width, height = targetSize.height)
33+ val enter = fadeIn() + expandVertically()
34+ val exit = fadeOut() + shrinkVertically()
35+ return (enter togetherWith exit) using SizeTransform { initialSize, targetSize ->
36+ this .contentAlignment
37+ if (targetState != null ) {
38+ keyframes {
39+ IntSize (width = targetSize.width, height = initialSize.height) at durationMillis / A_QUARTER
40+ IntSize (width = targetSize.width, height = targetSize.height)
41+ }
42+ } else {
43+ keyframes {
44+ IntSize (width = initialSize.width, height = initialSize.height) at durationMillis / A_QUARTER
45+ IntSize (width = initialSize.width, height = 0 )
46+ }
3947 }
4048 }
4149}
0 commit comments