Hi everyone, I’m implementing an iOS-like overscro...
# compose
k
Hi everyone, I’m implementing an iOS-like overscroll behavior and running into an animation continuity issue. I’m using an
Animatable
to represent the overscroll offset with spring animation. The intended
onFling
flow is:
overscroll settling → performFling(scroll) → overscroll again
Ideally, the velocity should stay continuous across these phases. The issue happens when the overscroll is settling back, for example when the previous frame has
offset.value > 0
, but the current frame crosses zero and enters the normal scroll phase. At that point, the offset should be clamped to
0
, but I’m not sure what velocity should be passed into
performFling
. If I pass the unclamped velocity from the frame that already crossed zero, there is a noticeable jump. My understanding is that we may need to compute the spring velocity exactly at the moment when the offset reaches
0
. Questions: 1. Does that guarantee velocity continuity from the overscroll phase into the scroll phase? Also, does
performFling
happen in the same frame after the overscroll reaches zero? 2. If there is remaining velocity after
performFling
and we need to start a new spring animation, it seems like there will be a one-frame delay, which also causes a visible jump. What is the recommended way to preserve velocity continuity across the entire fling: overscroll, normal scroll, and the next overscroll?
My rubber band function has unit velocity at zero (f'(0) = 1), so it's only the issue about the offset animation.