block by mbostock 1771630

Input Value Interpolation

Full Screen

This example uses a custom tween that interpolates the value property.

index.html

<!DOCTYPE html>
<meta charset="utf-8">
<style>

body {
  padding: 40px;
}

input {
  width: 880px;
}

</style>
<input type="range" value="0" min="0" max="255" step="any">
<script src="//d3js.org/d3.v3.min.js"></script>
<script>

d3.select("input").transition()
    .delay(1500)
    .duration(7500)
    .tween("value", valueTween(255));

function valueTween(value) {
  return function() {
    var i = d3.interpolateNumber(this.value, value);
    return function(t) { this.value = i(t); };
  };
}

</script>