Skip to content
This repository was archived by the owner on Jun 7, 2018. It is now read-only.
This repository was archived by the owner on Jun 7, 2018. It is now read-only.

Proposal: Easing as a function #169

@notoriousb1t

Description

@notoriousb1t

I propose that animations easings should be able to be specified as functions.

Reason
While cubic-bezier and step provide a good basis for most animations, there are easing functions that cannot be expressed through the existing CSS timing functions. For instance, creating a believable bounce in an animation requires setting easings on multiple keyframes. This is not a good scenario for reusability and doesn't empower developers to innovate in this area.

Also, this would be a good starting point for building more complex animation systems on top of WAAPI.

Here is an issue submitted for CSS that has a lot of ideas on the subject of advanced/complex timings: w3c/csswg-drafts#229

While I personally think JS functions don't belong there, I do think that in the Web Animation API, they would make a lot of sense.

Syntax
Using the keyframe syntax, it would look something like this for a linear function:

element.animate({
    /* ... */
    easing: function(offset) {
        // linear function
        return offset;
    }
})

Constraints
Since (I think) cubic bezier functions can overshoot 100% progression and undershoot 0% progression, I think it is reasonable that the returned offset should be able to be -Infinity to Infinity. If the function does not return a number, it should throw an error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions