Skip to content

Instantly share code, notes, and snippets.

@zocoi
Forked from mbostock/.block
Last active August 29, 2015 14:17
Show Gist options
  • Save zocoi/2088c19e9e48059e9a95 to your computer and use it in GitHub Desktop.
Save zocoi/2088c19e9e48059e9a95 to your computer and use it in GitHub Desktop.

An example of using transition.styleTween to avoid using the computed style value, and instead use the style value as-set.

<!DOCTYPE html>
<meta charset="utf-8">
<body>
<div style="width: 100px; height: 100px; background:brown;"/>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script>
function styleTween() {
return d3.interpolateString("translate(0,0)", "translate(50px, 50px)");
};
d3.select("div")
.styleTween("transform", styleTween)
.style("-webkit-transform", "translate(50px, 50px)");
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment