-
Notifications
You must be signed in to change notification settings - Fork 175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Compose] MotionLayout cannot animate the circle angle and distance together #848
Comments
The constraints in the constraintSet define the position for the start and end. Getting one object to have a path relative to another is not supported in the dsl syntax. orbit.mp4 |
I attempted to use JSON syntax and made changes to my code, as shown below: val jsonScene =
"""
{
Variables: {
angle: {
from: 0,
step: 51,
},
distance: 100,
angle2: {
from: 51,
step: 51,
},
distance2: 70,
mylist: {
tag: 'unSelectedColorList',
},
},
ConstraintSets: {
start: {
selectedColor: {
width: 5,
height: 5,
center: 'parent',
},
Generate: {
mylist: {
width: 5,
height: 5,
circular: [
'parent',
'angle',
'distance',
],
},
},
},
end: {
selectedColor: {
width: 70,
height: 70,
center: 'parent',
},
Generate: {
mylist: {
width: 45,
height: 45,
circular: [
'parent',
'angle2',
'distance2',
],
},
},
},
},
Transitions: {
default: {
from: 'start',
to: 'end',
}
}
}
""".trimIndent()
val animateToEnd by remember { mutableStateOf(true) }
val progress = remember { Animatable(0f) }
LaunchedEffect(animateToEnd) {
delay(50)
progress.animateTo(
if (animateToEnd) 1f else 0f,
animationSpec = tween(5000)
)
}
MotionLayout(
motionScene = MotionScene(jsonScene),
modifier = Modifier.fillMaxSize(),
progress = progress.value,
debugFlags = DebugFlags.All,
) {
unSelectedColorList.forEachIndexed { index, colorItem ->
ColorItemComponent(
colorItem = colorItem,
modifier = Modifier
.layoutId("id${index}", "unSelectedColorList")
.clip(CircleShape),
)
}
ColorItemComponent(
colorItem = selectedColor,
modifier = Modifier
.border(
width = 3.dp,
color = Color(white),
shape = CircleShape
)
.layoutId("selectedColor")
.clip(CircleShape),
)
} However, the behavior appears to be unexpected. It seems that all constraint nodes within the list are being ignored. Screen_recording_20231206_002958.mp4 |
Description
I intent to implement a path motion using MotionLayout. I set up a start
constraintSet
with an initialangle
of51f
anddistance
of0
. Subsequently, I Configured an endconstraintSet
withangle
set to0f
anddistance
set to70.dp
.What happened?
I observed that the only one of
angle
anddistance
can be animated at a time, as demonstrated in the video below.Screen_recording_20231204_231220.mp4
Expected Behavior
I expect both
angle
anddistance
to be animated simultaneously. The desired path is illustreated in the accompanying image:Env
Full code
Sample Project
For your convenience, I have prepared a sample project.
ConstraintLayoutComposeCircleReproduce.zip
The text was updated successfully, but these errors were encountered: