Skip to content

[css-easing-2] Bikeshed function name for custom easings #7419

Closed
@jakearchibald

Description

@jakearchibald

What should we call the function that allows developers to define custom easings?

Feature description

The arguments are a comma-separated groups of:

  • Output (number)
  • Start input (optional, percentage)
  • End input (optional, percentage)

The values work very similar to linear-gradient.

function-name(0, 0.7, 0.87, 0.98, 1) - this creates 5 points:

Screenshot 2021-08-23 at 13 11 21

Which is equivalent to function-name(0 0%, 0.7 25%, 0.87 50%, 0.98 75%, 1 100%), as points without a 'start input' are given one automatically (using the same process as linear gradients).

The third value, again similar to gradients, can be used to create an extra point using the same output value. So function-name(0, 0.5 25% 75%, 1) creates 4 points:

Screenshot 2021-08-23 at 08 52 21

Output values will typically be 0-1, but can be outside of that, as they can with cubic-bezier. A likely usage here will be elastic/spring easings.

Similarly, input values will typically be 0%-100%, but can extend beyond that to provide points for edge-cases where easings are chained.

The ends of the graph automatically extend beyond their specified point using their final angle, so the previous easing (function-name(0, 0.5 25% 75%, 1)) would extend like this:

Screenshot 2021-08-23 at 09 00 32

However, if the final two points are in the same position, the line extends horizontally, so function-name(0, 0.5 25% 75%, 1 100% 100%) (the difference being the 100% 100% at the end), would be:

Screenshot 2021-08-23 at 09 02 27

Option 1: linear()

Why:

  • linear is already an easing keyword. It would be redefined to be shorthand for linear(0, 1).
  • The interpolation is 'linear' between points.
  • The syntax is similar to linear-gradient(), which starts with linear (although there 'linear' mostly refers to direction than interpolation).

Why not:

People seem initially confused by this, as they expect linear to be a single line. When I explain "but it's still linear, but between points", they roll their eyes as if I've found a loophole 😄

Option 2: linear-spline()

Why:

  • 'spline' is often used when interpolating between points.

Why not:

  • It often evokes curves, which this isn't really.

Option 3: ease()

Why:

  • It's the definition of an easing. Naming similar to keywords ease, ease-in, ease-out etc.
  • Leaves the door open for defining a non-linear interpolation between two points, without having to use a new function name. Eg something like ease(0, ease-out to 0.5, ease-in to 1)

Why not:

  • ease already exists as a shothand keyword for cubic-bezier(0.25, 0.1, 0.25, 1), so the keyword usage is pretty different to the function usage.
  • Perhaps it won't make sense to add curves this way, and we'd need to find a new function name for that.

Option 3.5: easing()

As above, but avoids the naming clash with the keyword ease.

Option 4: piecewise()

Why:

Why not:

  • It isn't that totally like the concept, as the function always interpolates between points.
  • I wasn't aware of the term before someone suggested it. Maybe it's obscure?
  • The name doesn't communicate that it produces an easing function.

Note: This is a discussion of the function name only, not the format of the function overall.

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