Skip to content

Instantly share code, notes, and snippets.

@mbostock
Last active February 9, 2016 01:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbostock/1616423 to your computer and use it in GitHub Desktop.
Save mbostock/1616423 to your computer and use it in GitHub Desktop.
Transition Speed Test
license: gpl-3.0
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
width: 720px;
margin: 20px auto 20px auto;
}
#d3 {
outline: 1px red solid;
width: 720px;
overflow: hidden;
}
#d3 div {
width: 5px;
height: 5px;
background-color: white;
outline: 1px black solid;
float: left;
margin: 5px;
display: block;
}
</style>
<p><button id="click">Click me!</button> Built with <a href="https://d3js.org/">D3</a>. A response to Rich Bradshaw’s <a href="http://css3.bradshawenterprises.com/demos/speed.php">jQuery <i>vs.</i> CSS transition speed test</a>.
<div id="d3"></div>
<script src="//d3js.org/d3.v3.min.js"></script>
<script>
var div = d3.select("#d3").selectAll("div")
.data(d3.range(48 * 48))
.enter().append("div");
d3.select("#click").on("click", function() {
div
.style("background-color", null)
.style("outline-color", null)
.transition()
.duration(1000)
.style("background-color", "black")
.style("outline-color", "red");
});
</script>
@capitalist
Copy link

Nice, if I put d3.inlog on a transition it makes the example look like the jquery version because of the high overhead d3.inlog introduces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment