-
-
Notifications
You must be signed in to change notification settings - Fork 865
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
Support for linear()
easing function
#2812
Conversation
1e1a565
to
2880a44
Compare
ease in unsupportedEasingFunctions | ||
) { | ||
ease = | ||
unsupportedEasingFunctions[ | ||
ease as keyof typeof unsupportedEasingFunctions | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you made a type guard like:
function isUnsupportedEase(key: string): key is keyof typeof unsupportedEasintFunctions {
return key in unsupportedEasingFunctions
}
You could avoid the casts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ty will implement
import { EasingFunction } from "../../../../easing/types" | ||
import { progress } from "../../../../utils/progress" | ||
|
||
// Create a linear easing point for every 10 ms |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why 10ms btw?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just somewhere between 8 (120fps) and 16 (60fps) that looks quite good without being too accurate (as there's a resolution/performance tradeoff)
Currently, when a WAAPI animation is defined with an easing function:
Or an easing name not supported by WAAPI:
Then Motion will pre-generate keyframes for this animation and run it with
linear
easing.This can have poor performance characteristics: https://issues.chromium.org/issues/41491098
Likewise for complex values like
clip-path
andfilter
this can have the overhead of number -> string conversion.This PR adds support for the
linear()
easing function. So when an easing isn't supported by WAAPI, we generate alinear()
easing function instead of pre-generating keyframes.