Tash
02/24/2021, 11:16 PMManualAnimationClock.
In general what’s the declarative way to think about “freezing” and “resuming/reverting” animations, and are there any related APIs at the moment? Came across *Pausable*MonotonicFrameClock but seems like a lower level API 🤔Doris Liu
02/24/2021, 11:30 PMTash
02/24/2021, 11:31 PMTash
02/24/2021, 11:34 PMDoris Liu
02/24/2021, 11:43 PMTransition may not support that depending on what's the intended behavior for your Fling. Sounds like what could be helpful here is some form of seeking support for Transition, where you can control the progress explicitly.Doris Liu
02/24/2021, 11:52 PMAnimatable to animate a single progress, and derive other animation values from that progress. It's unfortunate, but hopefully we'll have an API for seeking soon.Tash
02/24/2021, 11:54 PMclass SwipeableItemState {
val animatableOffset = Animatable(Offset(0f, 0f), Offset.VectorConverter)
fun pause() {
/ ** pause whatever is going on at this point **/
}
fun flingAway() {
// Calculate fling target, determine custom endX,endY
animatableOffset.animateTo(
targetValue = Offset(endX, endY),
initialVelocity = startVelocity
)
}
}Tash
02/24/2021, 11:56 PManimateTo was in launch { } and the Job was prematurely cancelled….would that freeze the Animatable to wherever it was 🤔Doris Liu
02/25/2021, 12:01 AMstop() on the Animatable and store the velocity from the returned AnimationResult.endStateTash
02/25/2021, 12:02 AMRafs
03/07/2021, 9:42 AMDoris Liu
03/07/2021, 8:31 PM