Skip to content

Instantly share code, notes, and snippets.

@micahstubbs
Last active June 14, 2016 23:11
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 micahstubbs/019a3382e067b3e7aca0 to your computer and use it in GitHub Desktop.
Save micahstubbs/019a3382e067b3e7aca0 to your computer and use it in GitHub Desktop.
animating a badge with svg group transitions
license: CC0-1.0
<!DOCTYPE html>
<html>
<body>
<svg width="600" height="600">
<g class="badge otherBadge">
<circle r="45" transform="translate(100,100)" style="fill: #023474"></circle>
<circle r="20" transform="translate(100,100)" style="stroke: #9C824A; stroke-width: 15px; fill: #EF0107"></circle>
</g>
</svg>
<script src="https://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script>
d3.selectAll(".badge")
.transition("down")
.delay(600)
.duration(600)
.attr("transform","translate(100,200)")
.style('opacity', 0.5)
.each('end', function() {
d3.select(this)
.transition("up")
.delay(600)
.duration(600)
.attr("transform","translate(400,100)")
.style('opacity', 1)
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment