animejs
Version:
JavaScript animation engine
29 lines (24 loc) • 662 B
JavaScript
/**
* Anime.js - easings - ESM
* @version v4.3.6
* @license MIT
* @copyright 2026 - Julian Garnier
*/
import { ceil, floor, clamp } from '../../core/helpers.js';
/**
* @import {
* EasingFunction,
* } from '../../types/index.js'
*/
/**
* Steps ease implementation https://developer.mozilla.org/fr/docs/Web/CSS/transition-timing-function
* Only covers 'end' and 'start' jumpterms
* @param {Number} steps
* @param {Boolean} [fromStart]
* @return {EasingFunction}
*/
const steps = (steps = 10, fromStart) => {
const roundMethod = fromStart ? ceil : floor;
return t => roundMethod(clamp(t, 0, 1) * steps) * (1 / steps);
};
export { steps };