Status Update
Placement/reordering animations in lists: Available since 1.1.0
Placement/reordering animations in grids: Available since 1.2.0
Placement/reordering animations in staggered grids: Available since 1.5.x betas
Additions/removals animations: In progress
Comments
cl...@google.com <cl...@google.com>
an...@google.com <an...@google.com>
ra...@twinhealth.com <ra...@twinhealth.com> #2
Thanks! This looks like a bug, thank you for reporting!
an...@google.com <an...@google.com> #3
Dragging up to 10% or between 50% and 90% will cause it to snap back to the start anchor.
Dragging between 10% and 50% or past 90% will cause it to snap to the end anchor.
ro...@gmail.com <ro...@gmail.com> #4
Project: platform/frameworks/support
Branch: androidx-main
Author: Jossi Wolf <
Link:
Update AnchoredDraggable target calculation logic
Expand for full commit details
Update AnchoredDraggable target calculation logic
We were previously relying on currentValue and the next closest anchor in the drag direction, but the simpler and more reliable way is to look at the left and right anchors as the window.
Relnote: Fixed a bug where positional thresholds passed to AnchoredDraggableDefaults.flingBehavior were not considered correctly in some scenarios.
Test: anchoredDraggable_fling_offsetPastHalfwayBetweenAnchors_beforePosThreshold_doesntAdvance
Bug: 367660226
Bug: 366003852
Change-Id: Ifdf0dfcf3d7ff8288affee56e7092bbed473d6ab
Files:
- M
compose/foundation/foundation/src/androidInstrumentedTest/kotlin/androidx/compose/foundation/anchoredDraggable/AnchoredDraggableStateTest.kt
- D
compose/foundation/foundation/src/androidInstrumentedTest/kotlin/androidx/compose/foundation/anchoredDraggable/AnchoredDraggableTestState.kt
- M
compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/AnchoredDraggable.kt
Hash: eff53304942e9fd4fa5382e0cf487a734c5b8d28
Date: Thu Sep 19 16:24:55 2024
ka...@gmail.com <ka...@gmail.com> #5
sh...@gmail.com <sh...@gmail.com> #6
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.compose.foundation:foundation:1.8.0-alpha04
androidx.compose.foundation:foundation-android:1.8.0-alpha04
androidx.compose.foundation:foundation-jvmstubs:1.8.0-alpha04
ap...@google.com <ap...@google.com> #7
Using the new version 1.8.0-alpha04
does not seem to resolve the issue for me. I tested with the same setting as the reported issue:
// it doesn't matter what you put here a the multiplier, the positionalThreshold is always 50%
positionalThreshold = { d -> d * 0.9f },
velocityThreshold = { Float.POSITIVE_INFINITY },
ma...@gmail.com <ma...@gmail.com> #8
Same. I've run this again on 1.8.0-alpha04. When using
positionalThreshold = { d -> d * 0.1f }
Dragging up to 10% or between 50% and 90% will cause it to snap back to the start anchor. Dragging between 10% and 50% or past 90% will cause it to snap to the end anchor.
I would expect It to only return if dragged less than or equal to 10% and snap to the end if dragged greater than 10%.
When using
positionalThreshold = { d -> d * 0.9f }
It acts as if the threshold has been set to 50%.
From what I can tell, nothing has changed about the behavior.
an...@google.com <an...@google.com> #9
Thanks, we will investigate and update this issue.
ro...@gmail.com <ro...@gmail.com> #10
an...@google.com <an...@google.com> #11
Project: platform/frameworks/support
Branch: androidx-main
Author: Jossi Wolf <
Link:
Update AnchoredDraggable target calculation logic
Expand for full commit details
Update AnchoredDraggable target calculation logic
There was a missed case when the velocity was negative.
Test: New tests with more parameter permutations
Fixes: 367660226
Bug: 376931805
Relnote: "Follow-up fix for an issue in AnchoredDraggable's target calculation where it could settle at the wrong anchor for specific swipes."
Change-Id: I23b8773d3a694aa3c8de6a8f34b9d7fb54cfe560
Files:
- M
compose/foundation/foundation/src/androidInstrumentedTest/kotlin/androidx/compose/foundation/anchoredDraggable/AnchoredDraggableStateTest.kt
- M
compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/AnchoredDraggable.kt
Hash: 6a23aa4ee37ba171475e4155db0d24c90b358c7e
Date: Fri Nov 08 14:11:31 2024
sh...@gmail.com <sh...@gmail.com> #12
What is the fix version?
an...@google.com <an...@google.com> #13
We will comment on the issue when it has been included in a release. Until then, you can try the snapshot versions from androidx.dev.
om...@gmail.com <om...@gmail.com> #14
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.compose.foundation:foundation:1.8.0-alpha07
androidx.compose.foundation:foundation-android:1.8.0-alpha07
androidx.compose.foundation:foundation-jvmstubs:1.8.0-alpha07
androidx.compose.foundation:foundation-linuxx64stubs:1.8.0-alpha07
an...@google.com <an...@google.com> #15
sl...@gmail.com <sl...@gmail.com> #16
#15, please report a new issue with a full reproduction case and the versions you are using. Thank you!
co...@gmail.com <co...@gmail.com> #17
Running compose foundation 1.8.0-alpha07
I'm using AnchoredDraggable with nested scrolling. When I drag and release the lazy layout sometimes the draggable settles correctly and sometimes it doesn't even when i drag and release past the threshold (positionalThreshold = { distance -> distance / 2f }.
internal fun nestedScrollConnection(
dragState: AnchoredDraggableState<Anchors>,
decayAnimationSpec: DecayAnimationSpec<Float>,
orientation: Orientation = Orientation.Vertical,
): NestedScrollConnection = object : NestedScrollConnection {
override fun onPreScroll(
available: Offset,
source: NestedScrollSource,
): Offset {
val availableDelta = available.toFloat()
return if (
availableDelta < 0f
) dragState.dispatchRawDelta(availableDelta).toOffset()
else Offset.Zero
}
override fun onPostScroll(
consumed: Offset,
available: Offset,
source: NestedScrollSource,
): Offset {
val availableDelta = available.toFloat()
return if (
availableDelta >= 0f
) dragState.dispatchRawDelta(availableDelta).toOffset()
else Offset.Zero
}
override suspend fun onPreFling(
available: Velocity,
): Velocity {
val availableDelta = available.toFloat()
val consumedOffset = if (availableDelta < 0f) dragState.animateToWithDecay(
velocity = availableDelta,
targetValue = Anchors.Collapsed,
decayAnimationSpec = decayAnimationSpec,
) else 0f
return Velocity(
x = 0f,
y = consumedOffset,
)
}
override suspend fun onPostFling(
consumed: Velocity,
available: Velocity,
): Velocity {
val availableDelta = available.toFloat()
if (
availableDelta > 0f
) dragState.animateToWithDecay(
velocity = availableDelta,
targetValue = Anchors.Expanded,
decayAnimationSpec = decayAnimationSpec,
)
dragState.settle(animationSpec = spring())
return Velocity(x = 0f, y = availableDelta)
}
private fun Float.toOffset(): Offset = Offset(
y = if (orientation == Orientation.Vertical) this else 0f,
x = if (orientation == Orientation.Horizontal) this else 0f,
)
@JvmName("offsetToFloat")
private fun Offset.toFloat() = if (orientation == Orientation.Horizontal) x else y
@JvmName("velocityToFloat")
private fun Velocity.toFloat() = if (orientation == Orientation.Horizontal) x else y
}
jd...@google.com <jd...@google.com> #18
Hi, this seems to be a different issue. Please provide a full reproducer in a new issue so we can investigate. Thank you!
ch...@gmail.com <ch...@gmail.com> #19
Or, is there some way to look up which is the first build to contain the change?
ka...@gmail.com <ka...@gmail.com> #20
Looking at the release notes (
an...@google.com <an...@google.com> #21
Unfortunately, this still does not work. I'm on 1.8.0-alpha07 and when I use 0.9f from the original example it still snaps at 50%.
ka...@gmail.com <ka...@gmail.com> #22
#21, are you using exactly the same code shared in #1?
ma...@quantox.com <ma...@quantox.com> #23
Yes, I'm the OP.
an...@google.com <an...@google.com> #24
sdkmanager "build-tools;build-tools-version"
ra...@twinhealth.com <ra...@twinhealth.com> #25
Apologies #23, but I am not able to reproduce the issue with the sample from #1, running on Compose 1.8.0-alpha08. Can you please provide a full reproducer project as a zip? Thanks!
ka...@gmail.com <ka...@gmail.com> #26
Can confirm that positionalThreshold doesn't work, still snaps at 50%.
Here is composable I'm using to test:
@Composable
fun AnchoredDraggableAnchorsFromCompositionSample() {
val density = LocalDensity.current
val state = rememberSaveable(saver = AnchoredDraggableState.Saver()) {
AnchoredDraggableState(initialValue = DragAnchors.Start)
}
val draggableWidth = 200.dp
val containerWidthPx = with(density) { draggableWidth.toPx() }
// Our anchors depend on the density which is obtained from composition, so we update them using
// updateAnchors whenever they are available
SideEffect {
state.updateAnchors(
DraggableAnchors {
DragAnchors.Start at 0f
DragAnchors.End at containerWidthPx
}
)
}
Box(Modifier.width(draggableWidth).background(Color.Gray)) {
Box(Modifier
.size(50.dp)
.offset { IntOffset(x = state.requireOffset().roundToInt(), y = 0) }
.anchoredDraggable(
state,
Orientation.Horizontal,
flingBehavior =
AnchoredDraggableDefaults.flingBehavior(
state,
positionalThreshold = { distance -> distance * 0.95f }
)
)
.background(Color.Red)
)
}
}
kl...@gmail.com <kl...@gmail.com> #27
ka...@gmail.com <ka...@gmail.com> #28
kl...@gmail.com <kl...@gmail.com> #29
an...@google.com <an...@google.com> #30
il...@gmail.com <il...@gmail.com> #31
Can you please provide any status update / dates if possible?
rl...@gmail.com <rl...@gmail.com> #32
pe...@gmail.com <pe...@gmail.com> #33
jo...@google.com <jo...@google.com> #34
Hi, the Play store team is working on a feature which could greatly benefit from LazyColumn's addition/deletion animation support. Do you have an updated ETA that you can share with you? Thanks!
da...@gmail.com <da...@gmail.com> #35
ry...@google.com <ry...@google.com> #36
ka...@gmail.com <ka...@gmail.com> #37
its almost been 2 years now and even your internal teams at play store are asking for the item addition deletion animations, I was the first to bring this up in this thread first.
Is there any ETA on this ? It was a core functionality with DiffUtils which we shouldnt find workarounds as an implementation for Compose !
Could anyone from Google please share an ETA on this
an...@google.com <an...@google.com> #38
Hello. We are currently finializing the design for the underlying mechanism we will be using for the disappearance animations. Sorry, we can't give exact estimations, but I can reassure you this feature is in works
mo...@gmail.com <mo...@gmail.com> #39
ka...@gmail.com <ka...@gmail.com> #40
bro
ka...@gmail.com <ka...@gmail.com> #41
I kind of agree with the last poster, if we all "bro" the developers every year or month to bump the thread, they might feel pressured to finish the removal/addition animations. Anyways, hang in there champ, they're probably almost done with that last piece of work
se...@gmail.com <se...@gmail.com> #42
it...@gmail.com <it...@gmail.com> #43
ta...@gmail.com <ta...@gmail.com> #44
Yesterday was the 4th year open anniversary of this issue lol
it...@gmail.com <it...@gmail.com> #45
mu...@gmail.com <mu...@gmail.com> #46
ph...@gmail.com <ph...@gmail.com> #47
ap...@google.com <ap...@google.com> #49
Branch: androidx-main
commit 36578696db7997ec73d1f81ae55e6b61951e7895
Author: Andrey Kulikov <andreykulikov@google.com>
Date: Tue Jul 04 16:14:07 2023
Item disappearance animation for lazy lists
We add support for the disappearance animation for lazy list items. The appearance animation was added as an internal api as part of aosp/2644850. We are using the new graphics layer implementation we recently added as part of aosp/2969199 and a set of preceding cls. This new graphics layer implementation is automatically counting the amount of usages for each layer, meaning that even when the layer is technically released by its main user, the underlying drawn content is not discarded until all the parent layers stop drawing it as well. It allows us to continue drawing the item being removed for the duration of disappearance animation. This logic was added in aosp/2967570.
As part of this cl we made both appearance and disappearance animation support public for LazyColumn and LazyRow. Support for other lazy layouts will be added in the next cls. Support for other types of animations is tracked in
Fixes: 150812265
Relnote: Item appearance and disappearance animation support was added into `LazyColumn` and `LazyRow`. Previously it was possible to add `Modifier.animateItemPlacement()` modifier in order to support placement (reordering) animations. We deprecated this modifier and introduced a new non-experimental modifier called `Modifier.animateItem()` which allows you to support all three animation types: appearance (fade in), disappearance (fade out) and reordering.
Test: new LazyListItemDisappearanceAnimationTest
Change-Id: I2d7f7a376cea26c0a36a59a4586d2705ab04cab7
M compose/animation/animation/integration-tests/animation-demos/src/main/java/androidx/compose/animation/demos/lookahead/LookaheadWithAnimateItemPlacement.kt
M compose/foundation/foundation/api/current.txt
M compose/foundation/foundation/api/restricted_current.txt
M compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/LazyColumnDragAndDropDemo.kt
M compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/ListDemos.kt
M compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/PopularBooksDemo.kt
M compose/foundation/foundation/integration-tests/lazy-tests/src/androidTest/kotlin/androidx/compose/foundation/lazy/list/LazyListItemAppearanceAnimationTest.kt
A compose/foundation/foundation/integration-tests/lazy-tests/src/androidTest/kotlin/androidx/compose/foundation/lazy/list/LazyListItemDisappearanceAnimationTest.kt
M compose/foundation/foundation/integration-tests/lazy-tests/src/androidTest/kotlin/androidx/compose/foundation/lazy/list/LazyListItemPlacementAnimationTest.kt
M compose/foundation/foundation/integration-tests/lazy-tests/src/androidTest/kotlin/androidx/compose/foundation/lazy/list/LazyListTest.kt
M compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/LazyDslSamples.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/LazyItemScope.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/LazyItemScopeImpl.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/LazyList.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/LazyListItemAnimator.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/LazyListMeasure.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/LazyListMeasuredItem.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/grid/LazyGridItemPlacementAnimator.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/grid/LazyGridItemScopeImpl.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/layout/LazyLayoutAnimation.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/staggeredgrid/LazyStaggeredGridItemPlacementAnimator.kt
M compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/staggeredgrid/LazyStaggeredGridItemScope.kt
an...@google.com <an...@google.com> #50
Item appearance and disappearance animation support was added into LazyColumn
and LazyRow
. Previously it was possible to add Modifier.animateItemPlacement()
modifier in order to support placement (reordering) animations. We deprecated this modifier and introduced a new non-experimental modifier called Modifier.animateItem()
which allows you to support all three animation types: appearance (fade in), disappearance (fade out) and reordering.
This change is expected to be released as part of 1.7.0-alpha06
release.
Port of this modifier into lazy grids is tracked here:
To staggered grids here:
Support of other animation types aside of fade in/fade out is tracked here:
ca...@gmail.com <ca...@gmail.com> #51
Failed to transform lifecycle-livedata-core-2.8.0-alpha04.aar (androidx.lifecycle:lifecycle-livedata-core:2.8.0-alpha04) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=26, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-runtime}.
Caused by: [CIRCULAR REFERENCE: java.lang.NullPointerException]
When I try to use 1.7.0-alpha06, any recommendation?
ry...@google.com <ry...@google.com> #52
@
lo...@gmail.com <lo...@gmail.com> #53
Hello, in the doc, under the heading "Item animations", the last sentence that references this issue should be changed, or removed:
It still says:
Aside from reorderings, item animations for additions and removals is currently in development. You can track the progress in issue
. 150812265
jo...@google.com <jo...@google.com> #54
Thank you for letting us know! We've updated the documentation page :)
Description
Placement/reordering animations in lists: Available since 1.1.0
Placement/reordering animations in grids: Available since 1.2.0
Placement/reordering animations in staggered grids: Available since 1.5.x betas
Additions/removals animations: In progress