Update animation simulation to fix restart ballistic animation#100133
Update animation simulation to fix restart ballistic animation#100133MxSoul wants to merge 8 commits intoflutter:masterfrom
Conversation
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
@Piinks Here's what I think: In the previous method:
In the new method:
|
03b1d51 to
790997f
Compare
|
@Piinks
We could see sliding damping is not as great as before. The animation of clamping is same as without size change. |
Piinks
left a comment
There was a problem hiding this comment.
This is looking good.
@goderbauer can you give a second review?
|
|
||
| /// Update the simulation without restarting the animation. | ||
| /// | ||
| /// The current simulation will be replaced with the provided [Simulation]. |
There was a problem hiding this comment.
This could mean that the animation is making a jump if the simulations are very different at the current point in time? Since there is no smooth transition from one simulation to the next one, we should probably document that here.
|
|
||
| /// Update the simulation without restarting the animation. | ||
| /// | ||
| /// The current simulation will be replaced with the provided [Simulation]. |
There was a problem hiding this comment.
Also, it may be useful to add a little color to this doc describing when this API could be useful (and when not - with links to other API methods that may be more appropriate).
| late double _initVelocity; | ||
|
|
||
| late double _initPosition; |
There was a problem hiding this comment.
change late to final for both of these?
| double initVelocity = 0.0, | ||
| double initPosition = 0.0, |
There was a problem hiding this comment.
Somewhere we need to document what these parameters mean. Either in the constructor doc, or - if we can make them final as suggested below - you could make them public and document on there what they mean.
There was a problem hiding this comment.
I am especially curious to learn why these have the "init" prefix...
| /// Update the ballistic animation instead of restarting it, for example as the result of a layout change after a flinging gesture. | ||
| /// | ||
| /// The [initVelocity] and [initPosition] refer to the starting values of the new ballistic animation. | ||
| Simulation? updateBallisticAnimation(double initVelocity, double initPosition); |
There was a problem hiding this comment.
document: when does this return null? What does that mean?
packages/flutter/lib/src/widgets/scroll_position_with_single_context.dart
Show resolved
Hide resolved
| _initPosition, | ||
| ); | ||
| if (newSimulation != null) { | ||
| _controller.updateSimulation(newSimulation); |
There was a problem hiding this comment.
How is it guaranteed that this doesn't give as a discontinued animation with a big jump when we switch simulations? (see my other comment about this above)
Can you please update the PR description with an actual description of what this is fixing? I tried to follow the chain of links, but it is not clear to me. Is this fixing a perf regression? A fidelity problem? A bit of both? |
|
@MxSoul Do you still have plans to come back to this PR? |
|
@MxSoul I saw that you responded to some of the comments, did you maybe forget to push your updated code to this PR? |
|
Since there hasn't been a response, I am going to close this one for now. If you find the time to work on this again, feel free to reopen this with the feedback from above addressed. |


Same as #96512
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.