Skip to content

Instantly share code, notes, and snippets.

@realityking
Created September 15, 2014 18:46
Show Gist options
  • Save realityking/ef11511ad8d266bf13a7 to your computer and use it in GitHub Desktop.
Save realityking/ef11511ad8d266bf13a7 to your computer and use it in GitHub Desktop.
<html>
<head>
<style>
.something {
font: 700 300px sans-serif;
position: absolute;
}
</style>
<script>
function animate(element, color) {
var start = null;
function step(timestamp) {
if (start === null) {
start = timestamp;
}
progress = timestamp - start;
var steps = progress / 100;
var newColor = (color += steps) % 360;
var pretty = "hsl( "+newColor+", 100%, 60%)";
element.style.color = pretty;
requestAnimationFrame(step);
}
requestAnimationFrame(step);
}
document.addEventListener("DOMContentLoaded", function () {
for (var i = 0; i < 200; i++) {
var something = document.createElement('something');
something.innerText = 'YOLO';
something.className = 'something';
document.body.appendChild(something);
something.style.top = i;
something.style.left = i;
var color = 0 + parseInt(i*(360/200));
animate(something, color);
}
});
</script>
</head>
<body></bod>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment