Skip to content

Instantly share code, notes, and snippets.

Last active Jan 23, 2020
What would you like to do?
Text Transition II
license: gpl-3.0

A demonstration of transitioning text by fading-out the old element and fading-in a new replacement.

<!DOCTYPE html>
<meta charset="utf-8">
h1 {
font: 400 120px/500px "Helvetica Neue";
text-align: center;
width: 960px;
height: 500px;
margin: 0;
position: absolute;
<script src="//"></script>
var format = d3.format(",d");"h1")
.on("start", function repeat() {
var t =
.style("opacity", 0)
.style("opacity", 0)
.text(format(Math.random() * 1e6))
.style("opacity", 1)
.on("start", repeat);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment