Skip to content

Instantly share code, notes, and snippets.

@agarrharr
Last active August 29, 2015 14:22
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 agarrharr/bd59ffb45f0635667749 to your computer and use it in GitHub Desktop.
Save agarrharr/bd59ffb45f0635667749 to your computer and use it in GitHub Desktop.
Reorder the Dom II
<html>
<head>
<script src="http://d3js.org/d3.v3.min.js"></script>
</head>
<body>
<svg height="500px" width="500px">
<circle cx="100" cy="100" r="50" style="fill: #0091EA"></circle>
<circle cx="150" cy="100" r="50" style="fill: #00C853"></circle>
</svg>
<script>
d3.selectAll('circle').on('mouseenter', function() {
if (this !== d3.select('circle:last-child').node()) {
this.parentElement.appendChild(this);
d3.select(this)
.transition()
.duration(200)
.attr('r', 55)
.transition()
.ease('elastic')
.attr('r', 50);
}
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment