Skip to content

Instantly share code, notes, and snippets.

@bnolan
Created March 4, 2010 02:46
Show Gist options
  • Save bnolan/321343 to your computer and use it in GitHub Desktop.
Save bnolan/321343 to your computer and use it in GitHub Desktop.
/*
* A wiggley text thingy for jquery
*/
var WiggleText = function(message){
var el = $("<div></div>").addClass("wiggletext").css({position: 'absolute'});
for(i=0;i<message.length;i++){
$("<span>" + message.charAt(i) + "</span>").css({position: 'relative'}).appendTo(el);
}
el.appendTo("body");
el.css({
top : ($(window).height() - el.height()) / 2,
left : ($(window).width() - el.width()) / 2
});
var ticker = 0;
setInterval(function(){
var offset = ticker+=0.2;
el.find("span").each(function(){
var x = Math.cos(offset) * 15,
y = Math.sin(offset) * 15;
offset += 0.1;
$(this).css({
left : x,
top : y
});
})
}, 30);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment