Skip to content

Easings

js
import { 
easeInOutCubic
,
easeOutQuad
} from '@studiometa/js-toolkit/utils';
easeOutQuad
(0.5); // 0.75

An EasingFunction takes a 0 → 1 progress and returns a shaped 0 → 1 value.

Choosing one

Eight curves, three directions each. Every out and in-out is derived from its in.

CurveInOutIn-out
lineareaseLinear
quadeaseInQuadeaseOutQuadeaseInOutQuad
cubiceaseInCubiceaseOutCubiceaseInOutCubic
quarteaseInQuarteaseOutQuarteaseInOutQuart
quinteaseInQuinteaseOutQuinteaseInOutQuint
sineeaseInSineeaseOutSineeaseInOutSine
circeaseInCirceaseOutCirceaseInOutCirc
expoeaseInExpoeaseOutExpoeaseInOutExpo

Deriving one

ts
createEaseOut(easeIn: EasingFunction): EasingFunction
createEaseInOut(easeIn: EasingFunction): EasingFunction

Every out and in-out above is one of these applied to its in. Which means a custom curve gets its whole family for two lines:

ts
import { 
createEaseInOut
,
createEaseOut
, type
EasingFunction
} from '@studiometa/js-toolkit/utils';
const
easeInBack
:
EasingFunction
= (
progress
) =>
progress
*
progress
* (2.7 *
progress
- 1.7);
const
easeOutBack
=
createEaseOut
(
easeInBack
);
const
easeInOutBack
=
createEaseInOut
(
easeInBack
);

That is why only the eight in functions are written out and the other sixteen are derived: an out is an in run backwards, and writing it twice is how the two drift apart.

createEaseOut

ts
createEaseOut(easeIn: EasingFunction): EasingFunction

Mirror an in curve into its out.

createEaseInOut

ts
createEaseInOut(easeIn: EasingFunction): EasingFunction

Compose an in curve into its symmetric in-out.

Using one

js
import { 
easeOutCubic
,
lerp
} from '@studiometa/js-toolkit/utils';
function
positionAt
(
progress
) {
return
lerp
(0, 400,
easeOutCubic
(
progress
));
}

An easing shapes a progress, so it pairs with a value that already runs 0 → 1: a useScrollProgress() subscriber, or a map() of anything else.

They do not animate

There is no clock here — an easing is a pure function of a progress you already have.

  • For a value chasing a target frame by frame, use damp() or smoothTo().
  • For time-based playback, stagger and sequencing, that is the separate ui-animation package. tween and animate are not shipped.

The functions

Each takes a 0 → 1 progress and returns the shaped value.

easeLinear

ts
easeLinear(progress: number): number

The identity. It exists so a call site can name "no easing" rather than branch on undefined.

easeInQuad

ts
easeInQuad(progress: number): number

easeOutQuad

ts
easeOutQuad(progress: number): number

easeInOutQuad

ts
easeInOutQuad(progress: number): number

easeInCubic

ts
easeInCubic(progress: number): number

easeOutCubic

ts
easeOutCubic(progress: number): number

easeInOutCubic

ts
easeInOutCubic(progress: number): number

easeInQuart

ts
easeInQuart(progress: number): number

easeOutQuart

ts
easeOutQuart(progress: number): number

easeInOutQuart

ts
easeInOutQuart(progress: number): number

easeInQuint

ts
easeInQuint(progress: number): number

easeOutQuint

ts
easeOutQuint(progress: number): number

easeInOutQuint

ts
easeInOutQuint(progress: number): number

easeInSine

ts
easeInSine(progress: number): number

easeOutSine

ts
easeOutSine(progress: number): number

easeInOutSine

ts
easeInOutSine(progress: number): number

easeInCirc

ts
easeInCirc(progress: number): number

easeOutCirc

ts
easeOutCirc(progress: number): number

easeInOutCirc

ts
easeInOutCirc(progress: number): number

easeInExpo

ts
easeInExpo(progress: number): number

easeOutExpo

ts
easeOutExpo(progress: number): number

easeInOutExpo

ts
easeInOutExpo(progress: number): number

MIT Licensed