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 animating from 0 to non-number/pixel keyframe arrays #1310

Merged
merged 3 commits into from Nov 1, 2021

Conversation

mattgperry
Copy link
Collaborator

At some point during Motion 5 we started parsing all 0-unit values as 0 which erroneously failed this check.

Fixes #1308

@codesandbox-ci
Copy link

codesandbox-ci bot commented Oct 28, 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 73fe288:

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
framer-motion-keyframes-bug Issue #1308

@@ -191,6 +183,8 @@ const checkAndConvertChangedValueTypes = (
// as it'd be doing multiple resize-remeasure operations.
if (isKeyframesTarget(to)) {
const numKeyframes = to.length
from = to[0] ?? to[1]
Copy link
Contributor

Choose a reason for hiding this comment

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

Skimming through the diff, this seems to be the only line that has actually changed, and I don't understand how this change would fix the issue, could you provide additional context?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If it’s keyframes the “from” value was wrong previously - were actually animating from the values defined here

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 update line:189 as well for (let i = to[0] === null ? 1 : 0;. Technically it should always start from the next index we picked up for from right? Can the keyframes array contain undefined?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The first keyframe can be null, which basically is an instruction to use the current value. But yeah this should be a fromIndex, check out the updated version

@shuangq shuangq self-requested a review November 1, 2021 10:59
@mattgperry mattgperry added the automerge Land this PR label Nov 1, 2021
@mergetron mergetron bot merged commit e1794c2 into main Nov 1, 2021
@mergetron mergetron bot deleted the fix/keyframe-units branch November 1, 2021 12:13
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.

[BUG] Animations no longer support non-pixel values for keyframes
2 participants