Skip to content
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

Aborted Hero push transitions should retrace their flight path #12203

Merged
merged 6 commits into from
Sep 22, 2017

Conversation

HansMuller
Copy link
Contributor

Fix the animation jank that occurs when a push hero transition is popped before the transition has completed.

A similar fix should be made for the less common variation: a pop is interrupted by a push. This PR is incremental progress :-).

@Hixie
Copy link
Contributor

Hixie commented Sep 22, 2017

I need to think about this some more to have a coherent comment, but my first reaction is that I'm reluctant to remove the "always forward" invariant.

@HansMuller
Copy link
Contributor Author

I've revised the implementation to preserve the "always animate hero flights forward' invariant. That produced a nice simplification.

Added ReverseTween to tweens.dart.

@@ -178,6 +178,22 @@ class Tween<T extends dynamic> extends Animatable<T> {
String toString() => '$runtimeType($begin \u2192 $end)';
}

/// An [Tween] that evaluates its [parent] in reverse.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A, not An

final RenderBox finalRouteBox = manifest.toRoute.subtreeContext?.findRenderObject();
final Offset finalHeroOrigin = finalHeroBox.localToGlobal(Offset.zero, ancestor: finalRouteBox);
if (finalHeroOrigin != heroRect.end.topLeft) {
final Rect heroRectEnd = finalHeroOrigin & heroRect.end.size;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't feel super strongly about this but I think we should probably revert these back to using the word "to" instead of "final" so that they match "toHero".

_proxyAnimation.parent = new ReverseAnimation(newManifest.animation);

heroRect = _doCreateRectTween(heroRect.end, heroRect.begin);
heroRect = new ReverseTween<Rect>(heroRect);
} else if (manifest.type == _HeroFlightType.pop && newManifest.type == _HeroFlightType.push) {
// A pop flight was interrupted by a push.
assert(newManifest.animation.status == AnimationStatus.forward);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a TODO on this side to mention that we need to fix this too


await tester.pump(duration * 0.1);
expect(tester.getTopLeft(find.byKey(secondKey)).dx, closeTo(x0, epsilon));

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should probably add a comment for lines 1190 to 1200 (checking x3...x0) that while this is our current expectation, it's not as important as the test for x4. As in, we definitely don't want x4 to regress, because that would mean the hero lept, but it's not as critical that the path be consistent on the way back, so long as it is smooth and pretty.

@Hixie
Copy link
Contributor

Hixie commented Sep 22, 2017

LGTM

@HansMuller HansMuller merged commit c44aa26 into flutter:master Sep 22, 2017
@HansMuller HansMuller deleted the aborted_hero_flight branch September 22, 2017 22:33
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants