Easing Functions
Built-in Easings
Section titled “Built-in Easings”| Function | Family | Description |
|---|---|---|
linear | — | Constant speed, no acceleration |
easeInQuad | Quadratic | Accelerates from zero |
easeOutQuad | Quadratic | Decelerates to zero |
easeInOutQuad | Quadratic | Accelerates then decelerates |
easeInCubic | Cubic | Accelerates from zero (steeper) |
easeOutCubic | Cubic | Decelerates to zero (steeper) |
easeInOutCubic | Cubic | Accelerates then decelerates (steeper) |
easeInQuart | Quartic | Strong acceleration from zero |
easeOutQuart | Quartic | Strong deceleration to zero |
easeInOutQuart | Quartic | Strong acceleration then deceleration |
easeInSine | Sine | Gentle acceleration from zero |
easeOutSine | Sine | Gentle deceleration to zero |
easeInOutSine | Sine | Gentle acceleration then deceleration |
easeInExpo | Exponential | Explosive acceleration from zero |
easeOutExpo | Exponential | Explosive deceleration to zero |
easeInOutExpo | Exponential | Explosive acceleration then deceleration |
easeInBack | Back | Pulls back before accelerating |
easeOutBack | Back | Overshoots then settles |
easeInOutBack | Back | Pulls back, overshoots, then settles |
easeInElastic | Elastic | Spring-like wind-up |
easeOutElastic | Elastic | Spring-like overshoot oscillation |
easeInOutElastic | Elastic | Spring-like on both ends |
easeInBounce | Bounce | Bounces at the start |
easeOutBounce | Bounce | Bounces at the end |
easeInOutBounce | Bounce | Bounces at both ends |
Custom Easings
Section titled “Custom Easings”cubicBezier
Section titled “cubicBezier”Define a custom cubic-bezier curve, matching the CSS cubic-bezier() syntax.
import { cubicBezier } from 'elucim';
const myEasing = cubicBezier(0.25, 0.1, 0.25, 1.0);spring
Section titled “spring”Physics-based spring easing.
import { spring } from 'elucim';
const mySpring = spring({ mass: 1, stiffness: 100, damping: 10 });| Parameter | Type | Description |
|---|---|---|
mass | number | Mass of the object |
stiffness | number | Spring stiffness constant |
damping | number | Friction / damping coefficient |
With interpolate()
Section titled “With interpolate()”import { interpolate, easeOutCubic } from 'elucim';
const value = interpolate(progress, [0, 1], [0, 300], { easing: easeOutCubic,});With the Transform easing prop
Section titled “With the Transform easing prop”<Transform from={{ translateX: -100 }} to={{ translateX: 0 }} duration={30} easing={easeOutBack}> <Circle cx={200} cy={150} r={40} fill="#4f9eff" /></Transform>Code Example
Section titled “Code Example”import { Player, Transform, Circle, easing } from '@elucim/core';
<Player width={500} height={250} fps={30} durationInFrames={90}> <Transform from={{ translateX: -150 }} to={{ translateX: 150 }} duration={60} easing={easing.easeInOutCubic} > <Circle cx={250} cy={125} r={20} fill="#6c5ce7" /> </Transform></Player>{ "width": 500, "height": 250, "fps": 30, "durationInFrames": 90, "children": [ { "type": "circle", "cx": 250, "cy": 125, "r": 20, "fill": "#6c5ce7", "transform": { "fromTranslateX": -150, "toTranslateX": 150, "easing": "easeInOutCubic" } } ]}