Repository navigation
Fix velocity hand-off for hardware-accelerated springs - #3902
Open
mattgperry wants to merge 1 commit into
Open
mattgperry wants to merge 1 commit into
mattgperry wants to merge 1 commit into
Conversation
createGeneratorEasing builds a spring over 0 to 100, but passed it the velocity in the value's own units. An accelerated spring that interrupts another animation therefore started with the wrong speed, and, when moving towards a lower value, in the wrong direction. Scale velocity by 100 / (target - origin). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015HkhHt5hFXd2GyAsSEc2tv
Collaborator
Author
|
Generated by Claude Code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Matt · project thread
Before: when a spring runs as a WAAPI animation (for example
opacityorfilter) and interrupts a moving value, it started at the wrong speed. When it moved towards a lower value, it started in the wrong direction. For small ranges like opacity, the inherited velocity was almost lost.After: the WAAPI spring starts with the same velocity, and in the same direction, as the same spring on the main thread.
How:
createGeneratorEasingbuilds the spring over0to100and samples it into alinear()easing, but it passed the velocity in the value's own units. It now scales velocity by100 / (target - origin). Non-numeric keyframes (colours, filters) parse toNaNand keep the velocity as before.Tests: new
create-generator-easing.test.ts. It fails onmain(progress went forward when the velocity pointed away from the target) and passes now. motion-dom Jest and framer-motiontest-clientpass.Size budget: this adds about 35 B gzip, which takes the
animatescenario to 18,824 B (budget 18,800) anduseAnimateto 19,169 B (budget 19,150) inyarn size --check. I did not raise the budgets indev/inc/size-budgets.json, someasurewill fail until you decide on that.Found while prototyping in #3898 and #3900.
🤖 Generated with Claude Code
https://claude.ai/code/session_015HkhHt5hFXd2GyAsSEc2tv
Generated by Claude Code