1 line
1.3 KiB
Plaintext
1 line
1.3 KiB
Plaintext
{"version":3,"file":"steps.mjs","sources":["../../../src/easing/steps.ts"],"sourcesContent":["import { clamp } from \"../clamp\"\nimport type { EasingFunction } from \"./types\"\n\n/*\n Create stepped version of 0-1 progress\n\n @param [int]: Number of steps\n @param [number]: Current value\n @return [number]: Stepped value\n*/\nexport type Direction = \"start\" | \"end\"\n\nexport function steps(\n numSteps: number,\n direction: Direction = \"end\"\n): EasingFunction {\n return (progress: number) => {\n progress =\n direction === \"end\"\n ? Math.min(progress, 0.999)\n : Math.max(progress, 0.001)\n const expanded = progress * numSteps\n const rounded =\n direction === \"end\" ? Math.floor(expanded) : Math.ceil(expanded)\n\n return clamp(0, 1, rounded / numSteps)\n }\n}\n"],"names":[],"mappings":";;SAYgB,KAAK,CACjB,QAAgB,EAChB,YAAuB,KAAK,EAAA;IAE5B,OAAO,CAAC,QAAgB,KAAI;QACxB,QAAQ;AACJ,YAAA,SAAS,KAAK,KAAK;kBACb,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC;kBACzB,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAA;AACnC,QAAA,MAAM,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAA;QACpC,MAAM,OAAO,GACT,SAAS,KAAK,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QAEpE,OAAO,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC,CAAA;AAC1C,KAAC,CAAA;AACL;;;;"} |