Skip to content

Instantly share code, notes, and snippets.

@mbostock
Last active February 9, 2016 02:00
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/7367177 to your computer and use it in GitHub Desktop.
Save mbostock/7367177 to your computer and use it in GitHub Desktop.
Range Transition
license: gpl-3.0

Using transition.tween to transition a property.

<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
max-width: 640px;
margin: 40px auto;
}
input {
width: 100%;
}
</style>
<input type="range" min="0" max="1000" step="1" value="0">
<script src="//d3js.org/d3.v3.min.js"></script>
<script>
d3.select("input").transition()
.duration(7500)
.tween("value", function() {
var i = d3.interpolate(this.value, this.max);
return function(t) { this.value = i(t); };
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment