Skip to content

Instantly share code, notes, and snippets.

@YasuakiHirano
Created May 19, 2016 09:05
Show Gist options
  • Save YasuakiHirano/451662d8f9e03caa54e01ae067626277 to your computer and use it in GitHub Desktop.
Save YasuakiHirano/451662d8f9e03caa54e01ae067626277 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="jp">
<head>
<meta charset="UTF-8">
<title></title>
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script>
(function( $ ){
$.fn.www = function() {
var windowWidth = $(window).width();
var windowHeight = $(window).height();
var setchar = 'w';
this.css("height",windowHeight);
this.css("position","relative");
var myelm = this;
var j = 0;
setInterval(function(){
var strlen = Math.round(Math.random()*30) + 3;
var toprand = Math.round(Math.random()* windowHeight);
var boxstr = '';
var i = 0;
for(i = 0; i < strlen; i++){
boxstr = boxstr + setchar;
}
myelm.append("<div class='wbox' style='position:absolute;top:"+toprand+"px;left:0px;'>"+boxstr+"</div>");
$(".wbox").animate({"left":windowWidth + "px"}, { duration: 2500, easing: 'swing', });
},100);
};
})( jQuery );
function test(){
$("#hoge").www();
}
</script>
</head>
<body onload="test();">
<div id="hoge">
aaaa
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment