-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathloop.js
30 lines (29 loc) · 1.01 KB
/
loop.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
var limit = 50, // Max number of stars
body = document.body;
loop = {
//initilizeing
start: function() {
for (var i = 0; i <= limit; i++) {
var star = this.newStar();
star.style.top = this.rand() * 100 + "%";
star.style.left = this.rand() * 100 + "%";
star.style.webkitAnimationDelay = this.rand() + "s";
star.style.mozAnimationDelay = this.rand() + "s";
body.appendChild(star);
};
},
//to get random number
rand: function() {
return Math.random();
},
//createing html dom for star
newStar: function() {
var d = document.createElement('div');
d.innerHTML = '<figure class="star"><figure class="star-top"></figure><figure class="star-bottom"></figure></figure>';
return d.firstChild;
},
};
loop.start();
// DOM に新しく作られた要素とその内容を追加します。
// my_div = document.getElementClassName('about joinus');
// document.body.insertBefore(d, my_div);