easing-values.html 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <!DOCTYPE html>
  2. <body></body>
  3. <script src="../../include.js"></script>
  4. <script>
  5. test(() => {
  6. const easings = [
  7. "linear",
  8. "linear(0, 1)",
  9. "linear(0, 0.5, 1)",
  10. "linear(0 0%, 0.5 10%, 1 100%)",
  11. "linear(0% 0, 10% 0.5, 100% 1)",
  12. "linear(0% 0, 1 100%)",
  13. "linear(0 0% 50%, 1 50% 100%)",
  14. "linear(0.5 0% 100%)",
  15. // FIXME: "linear(-1, 2)"
  16. "ease",
  17. "ease-in",
  18. "ease-out",
  19. "ease-in-out",
  20. "cubic-bezier(0, 0, 0, 0)",
  21. "cubic-bezier(1, 1, 1, 1)",
  22. "cubic-bezier(1, 1000, 1, 1000)",
  23. // FIXME: "step-start",
  24. "step-end",
  25. "steps(1000)",
  26. "steps(10, jump-start)",
  27. "steps(10, jump-end)",
  28. "steps(10, jump-none)",
  29. "steps(10, jump-both)",
  30. // FIXME: "steps(10, start)",
  31. "steps(10, end)",
  32. ];
  33. for (const easing of easings) {
  34. const target = document.createElement('div');
  35. document.body.appendChild(target);
  36. println(easing);
  37. const animation = target.animate(
  38. { opacity: ['0', '1'] },
  39. {
  40. duration: 100,
  41. fill: 'forwards',
  42. easing: easing,
  43. });
  44. const computed_style = getComputedStyle(target);
  45. for (let time = 0; time <= 100; time += 10) {
  46. animation.currentTime = time;
  47. println(`${time}: ${parseFloat(computed_style.opacity).toFixed(2)}`);
  48. }
  49. target.remove();
  50. }
  51. });
  52. </script>