Skip to main content

Class: Easing

A utility class for creating easing functions. All generated easing functions are based on their CSS counterparts.

Constructors

constructor

new Easing(): Easing

Returns

Easing

Methods

back

back(end): (progress: number) => number

Creates a back easing function.

Parameters

NameTypeDescription
end"in" | "out" | "both"The end to which to apply easing.

Returns

fn

A back easing function.

▸ (progress): number

Parameters
NameType
progressnumber
Returns

number

Throws

Error if end is not one of 'in' | 'out' | 'both'.

Defined in

src/sdk/utils/controllers/Easing.ts:236


bezier

bezier(c1x, c1y, c2x, c2y, precompute?, minXResolution?, epsilon?, maxDepth?): (progress: number) => number

Creates a cubic bezier easing function. The function follows a cubic bezier curve with the endpoints fixed at (0, 0) and (1, 1).

The function can optionally use a precomputed lookup table. Using a lookup table may increase performance and/or precision of the created function at the cost of some precomputation time and memory needed to store the lookup table.

Parameters

NameTypeDefault valueDescription
c1xnumberundefinedThe x-coordinate of the first control point. Will be clamped to the range [0, 1].
c1ynumberundefinedThe y-coordinate of the first control point.
c2xnumberundefinedThe x-coordinate of the second control point. Will be clamped to the range [0, 1].
c2ynumberundefinedThe y-coordinate of the second control point.
precomputebooleanfalseWhether to precompute a lookup table. Defaults to false.
minXResolution?numberundefinedThe minimum resolution of the function along the x-axis. Defaults to 0.1 if precompute is true, or 1e-4 if precompute is false.
epsilonnumber1e-3The threshold of acceptable linear interpolation error used during precomputation. Ignored if precompute is false. Defaults to 1e-4.
maxDepthnumber10The maximum allowed recursive depth of precomputation. The number of additional lookup table breakpoints generated is bounded from above by 2 ^ (maxDepth) - 1. Ignored if precompute is false. Defaults to 10.

Returns

fn

A cubic bezier easing function.

▸ (progress): number

Parameters
NameType
progressnumber
Returns

number

Defined in

src/sdk/utils/controllers/Easing.ts:330


circ

circ(end): (progress: number) => number

Creates a circular easing function.

Parameters

NameTypeDescription
end"in" | "out" | "both"The end to which to apply easing.

Returns

fn

A circular easing function.

▸ (progress): number

Parameters
NameType
progressnumber
Returns

number

Throws

Error if end is not one of 'in' | 'out' | 'both'.

Defined in

src/sdk/utils/controllers/Easing.ts:198


cubic

cubic(end): (progress: number) => number

Creates a cubic easing function.

Parameters

NameTypeDescription
end"in" | "out" | "both"The end to which to apply easing.

Returns

fn

A cubic easing function.

▸ (progress): number

Parameters
NameType
progressnumber
Returns

number

Throws

Error if end is not one of 'in' | 'out' | 'both'.

Defined in

src/sdk/utils/controllers/Easing.ts:42


elastic

elastic(end): (progress: number) => number

Creates an elastic easing function.

Parameters

NameTypeDescription
end"in" | "out" | "both"The end to which to apply easing.

Returns

fn

An elastic easing function.

▸ (progress): number

Parameters
NameType
progressnumber
Returns

number

Throws

Error if end is not one of 'in' | 'out' | 'both'.

Defined in

src/sdk/utils/controllers/Easing.ts:282


exp

exp(end): (progress: number) => number

Creates an exponential easing function.

Parameters

NameTypeDescription
end"in" | "out" | "both"The end to which to apply easing.

Returns

fn

An exponential easing function.

▸ (progress): number

Parameters
NameType
progressnumber
Returns

number

Throws

Error if end is not one of 'in' | 'out' | 'both'.

Defined in

src/sdk/utils/controllers/Easing.ts:217


linear

linear(): (progress: number) => number

Creates a linear easing function.

Returns

fn

A linear easing function.

▸ (progress): number

Parameters
NameType
progressnumber
Returns

number

Defined in

src/sdk/utils/controllers/Easing.ts:13


polynomial

polynomial(order, end): (progress: number) => number

Creates a polynomial easing function.

Parameters

NameTypeDescription
ordernumberThe order of the polynomial.
end"in" | "out" | "both"The end to which to apply easing.

Returns

fn

A polynomial easing function.

▸ (progress): number

Parameters
NameType
progressnumber
Returns

number

Throws

Error if end is not one of 'in' | 'out' | 'both'.

Defined in

src/sdk/utils/controllers/Easing.ts:160


quad

quad(end): (progress: number) => number

Creates a quadratic easing function.

Parameters

NameTypeDescription
end"in" | "out" | "both"The end to which to apply easing.

Returns

fn

A quadratic easing function.

▸ (progress): number

Parameters
NameType
progressnumber
Returns

number

Throws

Error if end is not one of 'in' | 'out' | 'both'.

Defined in

src/sdk/utils/controllers/Easing.ts:23


quart

quart(end): (progress: number) => number

Creates a quartic easing function.

Parameters

NameTypeDescription
end"in" | "out" | "both"The end to which to apply easing.

Returns

fn

A quartic easing function.

▸ (progress): number

Parameters
NameType
progressnumber
Returns

number

Throws

Error if end is not one of 'in' | 'out' | 'both'.

Defined in

src/sdk/utils/controllers/Easing.ts:81


quint

quint(end): (progress: number) => number

Creates a quintic easing function.

Parameters

NameTypeDescription
end"in" | "out" | "both"The end to which to apply easing.

Returns

fn

A quintic easing function.

▸ (progress): number

Parameters
NameType
progressnumber
Returns

number

Throws

Error if end is not one of 'in' | 'out' | 'both'.

Defined in

src/sdk/utils/controllers/Easing.ts:120


sin

sin(end): (progress: number) => number

Creates a sinusoid easing function.

Parameters

NameTypeDescription
end"in" | "out" | "both"The end to which to apply easing.

Returns

fn

A sinusoid easing function.

▸ (progress): number

Parameters
NameType
progressnumber
Returns

number

Throws

Error if end is not one of 'in' | 'out' | 'both'.

Defined in

src/sdk/utils/controllers/Easing.ts:179


withEndpointParams

withEndpointParams(ease): (start: number, stop: number, progress: number) => number

Converts an easing function to one which supports arbitrary start and stop endpoints.

Parameters

NameTypeDescription
ease(progress: number) => numberAn easing function.

Returns

fn

A new easing function which generates the same shape as the specified function while supporting arbitrary start and stop endpoints.

▸ (start, stop, progress): number

Parameters
NameType
startnumber
stopnumber
progressnumber
Returns

number

Defined in

src/sdk/utils/controllers/Easing.ts:465


withEndpoints

withEndpoints(ease, start, stop): (progress: number) => number

Converts an easing function to one which uses specific start and stop endpoints.

Parameters

NameTypeDescription
ease(progress: number) => numberAn easing function.
startnumberThe start endpoint.
stopnumberThe stop endpoint.

Returns

fn

A new easing function which generates the same shape as the specified function while using the specified start and stop endpoints.

▸ (progress): number

Parameters
NameType
progressnumber
Returns

number

Defined in

src/sdk/utils/controllers/Easing.ts:479