Skip to content

Commit 3f7adbe

Browse files
authored
Update to new lazy list snippets. (#265)
1 parent 77e9ab1 commit 3f7adbe

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

compose/snippets/src/main/java/com/example/compose/snippets/lists/LazyListSnippets.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ package com.example.compose.snippets.lists
2020

2121
import androidx.compose.animation.AnimatedVisibility
2222
import androidx.compose.animation.ExperimentalAnimationApi
23+
import androidx.compose.animation.core.Spring
24+
import androidx.compose.animation.core.spring
2325
import androidx.compose.animation.core.tween
2426
import androidx.compose.foundation.ExperimentalFoundationApi
2527
import androidx.compose.foundation.horizontalScroll
@@ -434,7 +436,7 @@ private fun LazyItemAnimations() {
434436
// [START android_compose_layouts_lazy_column_item_animation]
435437
LazyColumn {
436438
items(books, key = { it.id }) {
437-
Row(Modifier.animateItemPlacement()) {
439+
Row(Modifier.animateItem()) {
438440
// ...
439441
}
440442
}
@@ -452,8 +454,10 @@ private fun LazyItemAnimationWithSpec() {
452454
LazyColumn {
453455
items(books, key = { it.id }) {
454456
Row(
455-
Modifier.animateItemPlacement(
456-
tween(durationMillis = 250)
457+
Modifier.animateItem(
458+
fadeInSpec = tween(durationMillis = 250),
459+
fadeOutSpec = tween(durationMillis = 100),
460+
placementSpec = spring(stiffness = Spring.StiffnessLow, dampingRatio = Spring.DampingRatioMediumBouncy)
457461
)
458462
) {
459463
// ...

0 commit comments

Comments
 (0)