Skip to content

[css-easing-2] Provide JavaScript API for CSS easing functions #6261

@mattgperry

Description

@mattgperry

With new proposals for complex easing functions, the amount of API surface JavaScript animation libraries are duplicating is to increase.

This is a waste of bundle size when these functions are already present in the browser. This cubic-bezier implementation alone can cost 1kb minified, so I'm eager that when new easing curves appear there's already requirement for them to be available to JS authors.

It would also ensure browser-based animation authoring tools like Framer could use the current browser's exact implementation when displaying and editing easing curves.

Proposal

A new Easing namespace, which contains access to the specced easing curves:

// cubic-bezier
const curve = Easing.cubicBezier(.17,.67,.83,.67)
const easedProgress = curve(0.5)

// steps
const stepped = Easing.steps(4, "end")
const easedProgress = stepped(0.5)

This would also allow the composition of easing functions:

stepped(curve(0.5))

And their usage outside of the Web Animations API, for instance drawing visualisations:

Screenshot of Framer's bezier editing tool

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions