Skip to content
Create a gist now

Instantly share code, notes, and snippets.

@maelp /README.md
Last active

Fast prototyping tricks - Glowing screen
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
width: 960px;
padding-top: 40px;
margin: auto;
position: relative;
}
svg {
width: 100%;
max-height: 400px;
}
</style>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script type='text/javascript'>
function animateGrowingCircle(fromRadius, toRadius) {
var animateFunction = function () {
d3.select(this)
.attr('r', fromRadius)
.transition()
.duration(1000)
.attr('r', toRadius)
.transition()
.duration(1000)
.attr('r', fromRadius)
.each('end', function () {
d3.select(this).each(animateFunction);
});
};
return animateFunction;
}
window.addEventListener('load', function () {
d3.xml('iPhone.svg', 'image/svg+xml', function (error, data) {
d3.select('body').node().appendChild(data.documentElement);
var svg = d3.select('svg');
svg.select('#iPhoneGloss')
.style('pointer-events', 'none');
var circle = svg.select('#Circle');
var r = +circle.attr('r');
circle.on('click', function () {
d3.select(this)
.attr('r', r)
.transition()
.duration(500)
.attr('r', r * 2)
.transition()
.duration(500)
.attr('r', r);
});
});
});
</script>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.