-
Notifications
You must be signed in to change notification settings - Fork 4
/
test.html
116 lines (106 loc) · 2.33 KB
/
test.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<!doctype html>
<html>
<head>
<title></title>
<style rel="stylesheet">
#mosaiccontainer {
position: relative;
}
.box {
float: left;
padding: 5px;
border: 5px solid white;
font-family: sans-serif;
font-size: 30px;
line-height: 36px;
color: rgba(0,0,0,0.4);
border-radius: 10px;
}
.box.wide1 {
width: 80px;
background-color: #f99;
}
.box.wide2 {
width: 180px;
background-color: #ff6;
}
.box.wide3 {
width: 280px;
background-color: #6af
}
.box.high1 {
height: 80px;
}
.box.high2 {
height: 180px;
}
.box.high3 {
height: 280px;
}
#feedback {
position: fixed;
right: 0;
top: 0;
padding: 10px;
background-color: white;
}
</style>
</head>
<body>
<div id="mosaiccontainer">
</div>
<div id="feedback"></div>
</body>
<script src="lib/require.js"></script>
<script type="text/javascript">
function getRandomInt (min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function feedback( str ) {
setTimeout(function() {
document.getElementById('feedback').innerHTML = str + ' '+document.body.scrollHeight+'px';
}, 0);
}
require(['./mosaic'], function(mosaicModule) {
var begetMosaic = mosaicModule.beget;
var container = document.getElementById('mosaiccontainer');
var html = '';
for( var i = 0; i < 500; i += 1 ) {
var num;
var rand = getRandomInt(-5,9);
switch (true) {
case rand > 8:
num = 3;
break;
case rand > 5:
num = 2;
break;
default:
num = 1;
}
var num2 = getRandomInt(128,320);
html += '<div class="box wide'+num+' high'+num+'" style="hei ght:'+num2+'px">'+(i+1)+'</div>';
}
container.innerHTML = html;
var mosaic = begetMosaic(container, 100, 'top');
var normalTop = mosaic.setLocationSelector( 'top', 100 );
var experimentalTop = mosaic.setLocationSelector( 'top', 100 );
mosaic.useWastedSpace = true;
feedback('experimental');
mosaic.init();
mosaic.tile();
document.addEventListener('click', function() {
if (mosaic.locationSelector === experimentalTop) {
mosaic.useWastedSpace = false;
mosaic.locationSelector = normalTop;
feedback('top');
} else {
mosaic.locationSelector = experimentalTop;
mosaic.useWastedSpace = true;
feedback('experimental');
}
mosaic.tile();
}, false);
});
</script>
</html>