doc_end_delay.html 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <style>
  6. .target {
  7. width: 50px;
  8. height: 50px;
  9. background: blue;
  10. }
  11. </style>
  12. </head>
  13. <body>
  14. <div id="target1" class="target"></div>
  15. <div id="target2" class="target"></div>
  16. <div id="target3" class="target"></div>
  17. <div id="target4" class="target"></div>
  18. <script>
  19. /* globals KeyframeEffect, Animation */
  20. "use strict";
  21. let animations = [{
  22. id: "target1",
  23. frames: [{ opacity: 0, offset: 0 }, { opacity: 1, offset: 1 }],
  24. timing: {
  25. id: "endDelay_animation1",
  26. duration: 1000000,
  27. endDelay: 500000,
  28. fill: "none"
  29. }
  30. }, {
  31. id: "target2",
  32. frames: [{ opacity: 0, offset: 0 }, { opacity: 1, offset: 1 }],
  33. timing: {
  34. id: "endDelay_animation2",
  35. duration: 1000000,
  36. endDelay: -500000,
  37. fill: "none"
  38. }
  39. }, {
  40. id: "target3",
  41. frames: [{ opacity: 0, offset: 0 }, { opacity: 1, offset: 1 }],
  42. timing: {
  43. id: "endDelay_animation3",
  44. duration: 1000000,
  45. endDelay: -1500000,
  46. fill: "forwards"
  47. }
  48. }, {
  49. id: "target4",
  50. frames: [{ opacity: 0, offset: 0 }, { opacity: 1, offset: 1 }],
  51. timing: {
  52. id: "endDelay_animation4",
  53. duration: 100000,
  54. delay: 100000,
  55. endDelay: -1500000,
  56. fill: "forwards"
  57. }
  58. }];
  59. for (let {id, frames, timing} of animations) {
  60. let effect = new KeyframeEffect(document.getElementById(id),
  61. frames, timing);
  62. let animation = new Animation(effect, document.timeline);
  63. animation.play();
  64. }
  65. </script>
  66. </body>
  67. </html>