Skip to content

Instantly share code, notes, and snippets.

@curran
Last active July 30, 2016 00:13
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 curran/cbd4695616e8128049e2614464c4140c to your computer and use it in GitHub Desktop.
Save curran/cbd4695616e8128049e2614464c4140c to your computer and use it in GitHub Desktop.
[unlisted] D3 Transition Test
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>D3 Test</title>
<script src="https://d3js.org/d3.v4.js"></script>
</head>
<body>
<div style="position: absolute"></div>
<script>
var div = d3.select("div");
div
.style("left", "-50%")
.transition().duration(1000)
.style("left", "50%")
.tween("log", function () {
return function (t) {
console.log(div.style("left")); // will be something like -5470.53px to 523px
console.log(div.node().style.left); // will be something like -522.996% to 50%
};
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment