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

Pregenerating keyframes for unsupported easing functions #1834

Merged
merged 4 commits into from Dec 16, 2022

Conversation

mattgperry
Copy link
Collaborator

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.

@mattgperry mattgperry requested a review from nvh December 16, 2022 11:00
Comment on lines 5 to 7
!easing ||
Array.isArray(easing) ||
(typeof easing === "string" && supportedWaapiEasing[easing])
Copy link
Contributor

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?

Copy link
Collaborator Author

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

Copy link
Contributor

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[]) {
Copy link
Contributor

@nvh nvh Dec 16, 2022

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.

Suggested change
export function isEasingSupported(easing?: Easing | Easing[]) {
export function isWaapiSupportedEasing(easing?: Easing | Easing[]) {

Copy link
Contributor

@nvh nvh left a 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.

@mattgperry mattgperry requested a review from nvh December 16, 2022 14:49
Comment on lines 5 to 7
!easing ||
Array.isArray(easing) ||
(typeof easing === "string" && supportedWaapiEasing[easing])
Copy link
Contributor

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

@mattgperry mattgperry added the automerge Land this PR label Dec 16, 2022
@mergetron mergetron bot merged commit f0a15c2 into fix/waapi-easing Dec 16, 2022
@mergetron mergetron bot deleted the feature/more-easing branch December 16, 2022 14:57
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