-
Notifications
You must be signed in to change notification settings - Fork 0
/
shotgun.js
21 lines (20 loc) · 833 Bytes
/
shotgun.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
var shotgunReload = function() {
var shells = [].slice.call(document.getElementsByClassName("shotgun"));
shells.forEach(function(element) {
if ((' ' + element.className + ' ').indexOf(' ' + "shot" + ' ') === -1) {
element.classList.add("shot");
var width = element.offsetWidth;
var height = element.offsetHeight
element.style.position = "relative";
var children = [].slice.call(element.children);
children.forEach(function(child) {
child.style.position = "absolute";
child.style.left = (Math.random() * width) - (child.offsetWidth / 2);
child.style.top = (Math.random() * height) - (child.offsetHeight / 2);
});
}
});
}
window.onload = function() {
shotgunReload();
}