OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <meta name="viewport" content="width=device-width, user-scalable=no"> |
| 3 <container id="container"></container> |
| 4 <script> |
| 5 var N = 1000; |
| 6 var duration = 1000; |
| 7 var keyframe = 1; |
| 8 var targets = []; |
| 9 |
| 10 for (var i = 0; i < N; i++) { |
| 11 var target = document.createElement('target'); |
| 12 container.appendChild(target); |
| 13 targets.push(target); |
| 14 } |
| 15 |
| 16 function startAllAnimations() { |
| 17 keyframe ^= 1; |
| 18 targets.forEach(function(target) { |
| 19 target.className = 'keyframe' + keyframe; |
| 20 }); |
| 21 } |
| 22 |
| 23 requestAnimationFrame(startAllAnimations); |
| 24 setInterval(startAllAnimations, duration); |
| 25 |
| 26 requestAnimationFrame(function() { |
| 27 window.measurementReady = true; |
| 28 }); |
| 29 </script> |
| 30 |
| 31 <style> |
| 32 body { |
| 33 margin: 0; |
| 34 overflow: hidden; |
| 35 } |
| 36 container { |
| 37 display: flex; |
| 38 flex-flow: row wrap; |
| 39 width: 550px; |
| 40 height: 800px; |
| 41 background: lightgoldenrodyellow; |
| 42 } |
| 43 target { |
| 44 display: inline-block; |
| 45 width: 9px; height: 9px; |
| 46 background: magenta; |
| 47 transition: opacity 1000ms linear; |
| 48 } |
| 49 .keyframe0 { |
| 50 opacity: 0; |
| 51 } |
| 52 .keyframe1 { |
| 53 opacity: 1; |
| 54 } |
| 55 </style> |
OLD | NEW |