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

Fix layout animations for elements that only change layout relative to parent #1271

Merged
merged 4 commits into from Sep 23, 2021

Conversation

mattgperry
Copy link
Collaborator

Previously we weren't properly animating elements that DON'T change layout relative to the page/viewport but DO change layout relative to the parent.

@codesandbox-ci
Copy link

codesandbox-ci bot commented Sep 22, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 77e187c:

Sandbox Source
Framer Motion: Simple animation Configuration
App Store UI using React and Framer Motion Configuration
Framer Motion: Reorder animation Configuration
Framer Motion: growing item positionTransition issue Configuration
Framer Motion: Image lightbox Configuration

right: 390,
top: 160,
})
// matchViewportBox(newBox, {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we skipping this test? Is it no longer the expected behaviour?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ooooops thanks

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Please still pass

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

NOOOO

dev/projection/script-animate.js Show resolved Hide resolved
@@ -807,7 +814,11 @@ export function createProjectionNode<I>({
* a relativeParent. This will allow a component to perform scale correction
* even if no animation has started.
*/
if (!this.targetDelta && !this.relativeTarget) {
if (
this.safeToResolveRelativeTarget &&
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need this check? After the first time it should get a relative target right? 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah yeah I've removed it, I think this is not needed any more

@@ -893,7 +907,10 @@ export function createProjectionNode<I>({
if (!this.parent || hasTransform(this.parent.latestValues))
return undefined

if (this.parent.target && this.parent.layout) {
if (
(this.parent.target || this.parent.targetDelta) &&
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we just check targetDelta? When do we expecting target to be there but not targetDelta?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think maybe if we check for relativeTarget instead it'll catch both but earlier in the frame

@mattgperry mattgperry added the automerge Land this PR label Sep 23, 2021
@mergetron mergetron bot merged commit 66b6b16 into feature/perfect-projection Sep 23, 2021
@mergetron mergetron bot deleted the fix/relative-projection branch September 23, 2021 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Land this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants