Skip to content

Instantly share code, notes, and snippets.

@jordanorelli
Created December 23, 2011 03:23
Show Gist options
  • Save jordanorelli/1513020 to your computer and use it in GitHub Desktop.
Save jordanorelli/1513020 to your computer and use it in GitHub Desktop.
a circle appears and disappears
<script src="static/js/raphael-min.js"></script>
<span id="injection" style="display:none;">&nbsp;</span>
<script>(function() {
var $injection = $("#injection");
var $messageBody = $injection.parent(); // selects the <span> element that the message is written into.
var $username = $messageBody.siblings(".message-username");
$username.html("&nbsp;");
$injection.remove();
var containerId = 'a' + Math.random().toString(36).substring(2);
var containerTemplate = "<div id='{{id}}' style='width: {{width}}; border: {{border}};'>&nbsp;</canvas>";
var containerConfig = {
id: containerId,
width: '600px',
border: 'none'
};
var containerSrc = Mustache.to_html(containerTemplate, containerConfig);
$messageBody.append(containerSrc);
var paper = new Raphael(containerId, 600, 200);
paper.circle(120, 120, 40).animate({fill: "#223fa3", stroke: "#000", "stroke-width": 60, "stroke-opacity": 0.5}, 2000);
setTimeout(function(){
var $container = $('#'+containerId);
$container.animate({opacity: 0.0}, 1000, function() {
$messageBody.parent().animate({height: 0.0}, 1000, function() {
$messageBody.parent().remove();
});
});
}, 3000);
})();</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment