This example uses a custom tween that interpolates the value
property.
-
-
Save mbostock/1771630 to your computer and use it in GitHub Desktop.
Input Value Interpolation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
license: gpl-3.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment