A zero-dependency, pure JavaScript collection of Robert Penner’s easing equations, ported faithfully for use in custom animations, scroll effects, canvas, or time-based interpolation.
📦 Zero runtime dependencies • 🧪 No side effects • 🌲 Tree-shakable • ✨ Pure functions
Place src/ease.js in your project and import the default object or individual named functions:
// Import default collection objectimporteasefrom'./ease.js';// Or import named easing functions (tree-shaking friendly)import{easeOutExpo,easeInOutQuad}from'./ease.js';All functions follow the standard Penner signature:
easingFunction(time,begin,change,duration)| Parameter | Type | Meaning |
|---|---|---|
time | number | Elapsed time (e.g., elapsedMs) |
begin | number | Starting value (e.g., 0) |
change | number | Total change in value (e.g., 100 - 0 = 100) |
duration | number | Total animation duration (e.g., 500 ms) |
import{easeOutQuad}from'./ease.js';letstart=null;constduration=800;constfrom=0;constto=300;functionanimate(timestamp){if(start===null){start=timestamp;}constelapsed=timestamp-start;constprogress=Math.min(elapsed,duration);constvalue=easeOutQuad(progress,from,to-from,duration);progressBar.style.width=String(value)+"px";if(elapsed<duration){requestAnimationFrame(animate);}}requestAnimationFrame(animate);All standard Penner equations are included and exported in alphabetical order:
easeInCirc,easeInCubic,easeInExpo,easeInQuad,easeInQuart,easeInQuint,easeInSineeaseInOutCirc,easeInOutCubic,easeInOutExpo,easeInOutQuad,easeInOutQuart,easeInOutQuint,easeInOutSineeaseOutCirc,easeOutCubic,easeOutExpo,easeOutQuad,easeOutQuart,easeOutQuint,easeOutSinelinearTween
This library includes a zero-dependency, comprehensive browser-based verification suite (50+ assertions covering boundary points, interpolation curves, and type guards).
To run the test suite:
- Serve the repository using any static web server (e.g., Nginx, Caddy, or Python's
http.server). - Open
tests/index.htmlin your browser (e.g.,http://localhost/tests/index.html). - View results visually on the page or open Developer Tools (
F12-> Console) to inspect grouped log outputs and execution metrics.
See LICENSE