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
Pregenerating keyframes for unsupported easing functions #1834
Conversation
!easing || | ||
Array.isArray(easing) || | ||
(typeof easing === "string" && supportedWaapiEasing[easing]) |
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.
This is pretty weird logic to me.
Why is easing always supported if easing
is an array or easing is falsy?
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.
Easing is falsy === default easing
Easing is array === bezier curve
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.
Not 100% sure, but maybe we should add that as a comment. Not feeling strongly though, so do what you prefer
import { BezierDefinition, EasingDefinition } from "../../easing/types" | ||
import { BezierDefinition, Easing, EasingDefinition } from "../../easing/types" | ||
|
||
export function isEasingSupported(easing?: Easing | Easing[]) { |
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.
Ahhh, reading the rest of the code, I think this one needs to be called isSupportedEasing
🤯 .
And I guess isWaapiSupportedEasing
would be even better.
export function isEasingSupported(easing?: Easing | Easing[]) { | |
export function isWaapiSupportedEasing(easing?: Easing | Easing[]) { |
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.
Let's rename a bit.
!easing || | ||
Array.isArray(easing) || | ||
(typeof easing === "string" && supportedWaapiEasing[easing]) |
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.
Not 100% sure, but maybe we should add that as a comment. Not feeling strongly though, so do what you prefer
WAAPI doesn't support custom JavaScript easing functions and has a shorter list of supported easings than Framer Motion.
In #1830 we added some approximations of unsupported easings via
cubic-bezier
. This PR extends support to all easing functions by pre-generating the animation keyframes.In the future it'll be preferable to change this approach to generating a custom
linear()
easing similar to Motion One, but this doesn't have wide browser support yet.