Built with blockbuilder.org for bouncy-ball.
Last active
September 6, 2016 20:04
-
-
Save Fil/8f2acdb7af257cec631f7bafd033aea7 to your computer and use it in GitHub Desktop.
bouncy-ball
This file contains 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: mit |
This file contains 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> | |
<head> | |
<meta charset="utf-8"> | |
<script src="https://d3js.org/d3.v4.min.js"></script> | |
<style> | |
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0;background:black; } | |
circle { fill: lime; } | |
</style> | |
</head> | |
<body> | |
<script> | |
var svg = d3.select("body").append("svg") | |
.attr("width", 200) | |
.attr("height", 400) | |
.append('g') | |
.attr('transform', 'translate(100,76)'); | |
var ball = svg.append("circle") | |
.attr('r', 25); | |
bounce(); | |
function bounce() { | |
ball | |
.transition() | |
.duration(575) | |
.ease(d3.easeQuadIn) | |
.attr('cy', 260) | |
.transition() | |
.duration(575) | |
.ease(d3.easeQuadOut) | |
.attr('cy', 0) | |
.on('end', bounce); | |
} | |
</script> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment