summaryrefslogtreecommitdiffstats
path: root/devtools/client/animationinspector/test/doc_multiple_animation_types.html
blob: 318f14d0ae05af90ef1e403d5c8ba636a7ffc9c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <style>
    .ball {
      width: 80px;
      height: 80px;
      border-radius: 50%;
    }

    .script-animation {
      background: #f06;
    }

    .css-transition {
      background: #006;
      transition: background-color 20s;
    }

    .css-animation {
      background: #a06;
      animation: flash 10s forwards;
    }

    @keyframes flash {
      0% {
        opacity: 1;
      }
      50% {
        opacity: 0;
      }
      100% {
        opacity: 1;
      }
    }
  </style>
</head>
<body>
  <div class="ball script-animation"></div>
  <div class="ball css-animation"></div>
  <div class="ball css-transition"></div>

  <script>
    /* globals KeyframeEffect, Animation */
    "use strict";

    setTimeout(function () {
      document.querySelector(".css-transition").style.backgroundColor = "yellow";
    }, 0);

    let effect = new KeyframeEffect(
      document.querySelector(".script-animation"), [
        {opacity: 1, offset: 0},
        {opacity: .1, offset: 1}
      ], { duration: 10000, fill: "forwards" });
    let animation = new Animation(effect, document.timeline);
    animation.play();
  </script>
</body>
</html>