The shape — EasingFn
Every export is a function with easingName
metadata. Parametric easings extend the shape with frozen
defaults and a .with(partial)
builder. defineEasing /
defineParametricEasing wrap your own math in the
same contract.
type EasingFn = ((t: number) => number) & {
readonly easingName: string;
};
type ParametricEasing<P extends object> = EasingFn & {
readonly defaults: Readonly<P>;
with(params: Partial<P>): EasingFn;
};
Core curves
The eight named families — each in three variants
(in / out / inOut) plus
linear. power2* through
power4* are aliased as
cubic* / quart* / quint*
for GSAP / Penner-curve familiarity.
import {
linear, none,
power1In, power1Out, power1InOut,
power2In, power2Out, power2InOut,
power3In, power3Out, power3InOut,
power4In, power4Out, power4InOut,
sineIn, sineOut, sineInOut,
circIn, circOut, circInOut,
expoIn, expoOut, expoInOut,
backIn, backOut, backInOut,
elasticIn, elasticOut, elasticInOut,
bounceIn, bounceOut, bounceInOut,
steps,
} from "@vysmo/easings";
Builders
Parametric factories that build a curve from numeric inputs.
spring is physics-based;
bezier is exact CSS-style;
rough / wiggle add noise for gritty
motion; custom takes a sparse keyframe list and
interpolates piecewise.
import {
bezier,
spring,
rough,
wiggle,
slow,
anticipate,
expoScale,
custom,
} from "@vysmo/easings";
import {
gentleSpring, wobblySpring, stiffSpring, slowSpring, molassesSpring,
SPRING_PRESETS,
} from "@vysmo/easings";
Modifiers
Function-to-function transforms.
reverse, mirror, yoyo
are the everyday ones. chain stitches multiple
easings end-to-end with weights. blend linearly
interpolates between two; slice reads a sub-range
and renormalises.
import {
reverse,
mirror,
yoyo,
chain,
blend,
compose,
slice,
} from "@vysmo/easings";
const wobbleIn = mirror(spring.with({ stiffness: 320 }));
CSS export — /css
Three pure functions. toCSSLinear samples any
curve into a CSS linear() value;
toCSSBezier emits an exact
cubic-bezier(); toCSSKeyframes
pre-bakes the eased values into a @keyframes
block driving any CSS property.
import { toCSSLinear, toCSSBezier, toCSSKeyframes } from "@vysmo/easings/css";
const value = toCSSLinear(spring.with({ stiffness: 220 }), 32);
document.documentElement.style.setProperty("--ease-pop", value);
toCSSBezier(0.42, 0, 0.58, 1);
toCSSKeyframes(
"slideIn",
"transform",
(eased) => `translateX(${eased * 100}%)`,
bounceOut,
20,
);
Parsing & reduced motion
parseEasing(spec) accepts GSAP-compatible string
references — useful when easings come from a config file
or design tool. prefersReducedMotion() is the
OS-level check; respectReducedMotion(ease, fallback?)
wraps an easing so it falls back to linear (or
your choice) when reduced motion is set.
import { parseEasing } from "@vysmo/easings/parse";
parseEasing("power2.out");
parseEasing("back.out(2)");
parseEasing("elastic.out(1.2, 0.4)");
parseEasing("steps(5, start)");
parseEasing("cubic-bezier(.42, 0, .58, 1)");
import { prefersReducedMotion, respectReducedMotion } from "@vysmo/easings/reduced-motion";
if (prefersReducedMotion()) ease = linear;
animate({
ease: respectReducedMotion(spring.with({ stiffness: 220 })),
duration: 600,
});