linear.mjs 403 B

123456789101112
  1. const generateLinearEasing = (easing, duration, // as milliseconds
  2. resolution = 10 // as milliseconds
  3. ) => {
  4. let points = "";
  5. const numPoints = Math.max(Math.round(duration / resolution), 2);
  6. for (let i = 0; i < numPoints; i++) {
  7. points += easing(i / (numPoints - 1)) + ", ";
  8. }
  9. return `linear(${points.substring(0, points.length - 2)})`;
  10. };
  11. export { generateLinearEasing };