Created
May 19, 2016 12:54
-
-
Save YasuakiHirano/3510b1c7168726982cb45847fb83c6c6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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> | |
<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.kusa = function() { | |
var windowWidth = $(window).width(); | |
var windowHeight = $(window).height(); | |
var matflg = false; | |
var setchar = "w"; | |
var color = "#00ff00"; | |
var direction = 0; // 0:横 1:縦 | |
if(matflg){ | |
setchar = String.fromCharCode(111+Math.random()*33); | |
} | |
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 size = 27; | |
var boxstr; | |
if(matflg){ | |
boxstr = String.fromCharCode(0x3041+Math.random()*80); | |
} else { | |
boxstr = ""; | |
} | |
var i = 0; | |
for(i = 0; i < strlen; i++){ | |
if(matflg){ | |
boxstr = boxstr + String.fromCharCode(0x3041+Math.random()*80); | |
} else { | |
boxstr = boxstr + setchar; | |
} | |
} | |
if(direction == 0){ | |
myelm.append("<div class='wbox' style='position:absolute;top:"+toprand+"px;left:0px;color:"+color+";font-size:"+size+"px;'>"+boxstr+"</div>"); | |
$(".wbox").animate( | |
{"left":windowWidth + "px"}, | |
{duration: 6000, | |
easing: 'swing', | |
complete: function(){ this.remove(); } | |
}); | |
} else { | |
myelm.append("<div class='wbox' style='position:absolute;top:0px;left:"+toprand+"px;color:"+color+";font-size:"+size+"px;'>"+boxstr+"</div>"); | |
$(".wbox").animate( | |
{"top":windowWidth + "px"}, | |
{duration: 6000, | |
easing: 'swing', | |
complete: function(){ this.remove(); } | |
}); | |
} | |
},100); | |
}; | |
})( jQuery ); | |
function test(){ | |
$("body").kusa(); | |
} | |
</script> | |
<style> | |
body{background:black;} | |
</style> | |
</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