blob: a98700712d8fca8bd69296cb0e811b90b2beda86 (
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
|
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<style>
div {
background-color: lime;
height: 100px;
}
</style>
</head>
<body>
<script>
"use strict";
const DURATION = 100000;
const KEYFRAMES = { backgroundColor: ["lime", "red"] };
function createAnimation(effect, className, playbackRate = -1) {
const div = document.createElement("div");
div.classList.add(className);
document.body.appendChild(div);
effect.duration = DURATION;
effect.fill = "forwards";
const animation = div.animate(KEYFRAMES, effect);
animation.updatePlaybackRate(playbackRate);
animation.play();
}
createAnimation({}, "normal");
createAnimation({}, "normal-playbackrate-2", -2);
createAnimation({ delay: 50000 }, "positive-delay");
createAnimation({ delay: -50000 }, "negative-delay");
createAnimation({ endDelay: 50000 }, "positive-end-delay");
createAnimation({ endDelay: -50000 }, "negative-end-delay");
</script>
</body>
</html>
|