Konstantin Klassen
07/14/2023, 3:15 PMLookaheadScope. I checked this example, added some logs and what I see is not what I would expect. So after placementOffset is defined, I log target and placementOffset, expecting that those would be different when content moves, but they are always the same. Because of that, I could also just remove placementOffset and replace its usage with target and the change animation would still work. So when moving content, should intermediateLayout be called once with:
- placementOffset -> where the content was, and
- target -> where the content will be
or am I not understanding this correctly?
Also in this example, targetOffset is never read and offsetAnimation is not rememberedKonstantin Klassen
07/14/2023, 3:32 PMlookaheadScope for animatePlacementInScope and the receiver in the intermediateLayout lambda?Konstantin Klassen
07/15/2023, 8:41 AMKonstantin Klassen
07/15/2023, 9:23 AMprivate fun Modifier.animateInScope(lookaheadScope: LookaheadLayoutScope) = composed {
with(lookaheadScope) {
this@composed.onPlaced { lookaheadScopeCoordinates, layoutCoordinates ->
// Returns the lookahead position of this modifier in the local coordinates of the LookaheadLayout
val target = lookaheadScopeCoordinates
.localLookaheadPositionOf(sourceCoordinates = layoutCoordinates)
.round()
// Returns the current position of this modifier in the local coordinates of the LookaheadLayout
val current = lookaheadScopeCoordinates
.localPositionOf(
sourceCoordinates = layoutCoordinates,
relativeToSource = Offset.Zero
)
.round()
Log.d("foo", "$current -> $target")
}
}
}
This very basic example, without animation. I change size and alignment of a Composable in a Box, onPlaced is called, but current and target are always the same.
(409, 1069) -> (409, 1069)
(292, 1612) -> (292, 1612)
Could anyone help me to untie the knot in my head 🙏?Brian Mbigo
07/16/2023, 7:48 AMKonstantin Klassen
07/16/2023, 11:54 AMtargetOffset and placementOffset are always the sameDoris Liu
07/20/2023, 9:02 PMSo when moving content, shouldbe called once with:intermediateLayout
--> where the content was, andplacementOffset
-placementOffset is where the content wants to be right now.-> where the content will betarget
target is where the content will be. The former may or may not be the same as the latter. We achieve the animation by offset-ing the placement from placementOffset to animated offset.Brian Mbigo
07/21/2023, 6:59 PMplacementOffset might differ from target ?Doris Liu
07/24/2023, 6:20 PMplacementOffset is where things are placed in this current frame, which means sibling's animations could influence placementOffset . In contrast, target is where the node will be placed when all lookahead-based animations finish, which depends on the target of siblings animations.
In this example below, you can see target shown as the wireframes, whereas the current placement would be gradually changing as shown in the example below.Stylianos Gakis
07/24/2023, 6:27 PMDoris Liu
07/24/2023, 6:28 PM