Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | 3x 18x 18x 18x 18x | import { clamp } from '../utils/clamp'; import { Easing } from './types'; /* Create stepped version of 0-1 progress @param [int]: Number of steps @param [number]: Current value @return [number]: Stepped value */ export type Direction = 'start' | 'end'; export const steps = (steps: number, direction: Direction = 'end'): Easing => ( progress: number ) => { progress = direction === 'end' ? Math.min(progress, 0.999) : Math.max(progress, 0.001); const expanded = progress * steps; const rounded = direction === 'end' ? Math.floor(expanded) : Math.ceil(expanded); return clamp(0, 1, rounded / steps); }; |