OLD | NEW |
| (Empty) |
1 <style> | |
2 #container { | |
3 position: relative; | |
4 } | |
5 | |
6 #control { | |
7 position: absolute; | |
8 background-color: black; | |
9 width: 20px; | |
10 height: 0px; | |
11 } | |
12 | |
13 #target { | |
14 position: absolute; | |
15 left: 20px; | |
16 background-color: rgba(0, 128, 0, 0.25); | |
17 width: 280px; | |
18 height: 0px; | |
19 } | |
20 | |
21 .block { | |
22 padding-left: 30px; | |
23 border-bottom: 1px solid black; | |
24 box-sizing: border-box; | |
25 width: 300px; | |
26 height: 50px; | |
27 font-size: 20px; | |
28 } | |
29 </style> | |
30 | |
31 <div id="container"> | |
32 <div id="control"></div> | |
33 <div id="target"></div> | |
34 </div> | |
35 <script src="../bootstrap.js"></script> | |
36 <script> | |
37 var easings = [ | |
38 '', | |
39 'linear', | |
40 'ease-in-out', | |
41 'step-middle', | |
42 'steps(4, end)', | |
43 ]; | |
44 | |
45 var keyframeHeight = 50; | |
46 var timing = {duration: easings.length * 1000, fill: 'forwards'}; | |
47 | |
48 control.animate({height: easings.length * keyframeHeight + 'px'}, timing); | |
49 | |
50 var keyframes = []; | |
51 easings.forEach(function (easing, i) { | |
52 var textBlock = document.createElement('div'); | |
53 textBlock.textContent = easing.length ? easing : '<default>'; | |
54 textBlock.classList.add('block'); | |
55 container.appendChild(textBlock); | |
56 var keyframe = {height: i * keyframeHeight + 'px'}; | |
57 if (easing.length) { | |
58 keyframe.easing = easing; | |
59 } | |
60 keyframes.push(keyframe); | |
61 }); | |
62 keyframes.push({height: easings.length * keyframeHeight + 'px'}); | |
63 target.animate(keyframes, timing); | |
64 </script> | |
OLD | NEW |