-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample.html
90 lines (84 loc) · 2.32 KB
/
example.html
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<style>
body {
margin:0;
padding:0;
background:transparent;
}
#circles-holder {
width:600px;
height:400px;
margin:auto;
position:relative;
background:transparent;
}
.circle {
background:rgba(0,102,255,.7);
border:1px solid rgba(0,102,255,1);
position:absolute;
box-shadow: 0 0 35px #000;
}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="jquery.circlepacker.js"></script>
<script type="text/javascript">
$(document).ready(function() {
//
//CREATE CIRCLES
//circle content position and size
$('.circle').each(function() {
//create size of circle via random number
var size = Math.round(Math.random()*50+20);
//create randomly sized circles from divs
$(this).css({
'width':size,
'height':size,
'margin-left':-1*size/2,
'margin-top':-1*size/2,
borderRadius:size/2+1,
zIndex:size
})
})
//
//PACK CIRCLES
//1st PARAM: holds the jQuery object of circle elements
//2nd PARAM: holds the settings
$('#circles-holder').circlePacker($('.circle'),{
'damping':0.1, //amount to move during iterations
'dampingAccel' : 0.95, //How quickly should it come to a stop
'dampingCutoff' : 0.010, //for quicker stopping (less accuracy),
'callback' : function(circleHolder) {
//circleHolder is reference back to holder
console.log('Finished Packing '+circleHolder.children().length+' Circles');
}
});
})
</script>
</head>
<body>
<div id='circles-holder'>
<div class='circle'></div>
<div class='circle'></div>
<div class='circle'></div>
<div class='circle'></div>
<div class='circle'></div>
<div class='circle'></div>
<div class='circle'></div>
<div class='circle'></div>
<div class='circle'></div>
<div class='circle'></div>
<div class='circle'></div>
<div class='circle'></div>
<div class='circle'></div>
<div class='circle'></div>
<div class='circle'></div>
<div class='circle'></div>
<div class='circle'></div>
<div class='circle'></div>
<div class='circle'></div>
<div class='circle'></div>
</div>
</body>
</html>