-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathtest.html
More file actions
108 lines (99 loc) · 2.71 KB
/
test.html
File metadata and controls
108 lines (99 loc) · 2.71 KB
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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>ШРИ 2014 ЕКБ - Эквалайзер</title>
<script src="http://yastatic.net/jquery/1.11.1/jquery.js"></script>
<style>
.equalizer-wrapper {
float:left; margin: 0 20px 20px 0;
}
.equalizer {
overflow: hidden;
border:1px solid #ddd;
}
.equalizer.small {
width: 100px;
height: 100px;
}
.equalizer.normal {
width: 200px;
height: 200px;
}
.equalizer.big {
width: 300px;
height: 300px;
}
span {
transition: height 0.5s linear;
}
</style>
<script>
var k = true;
timeout = 500; // synced with css
function setEqualizer(currentValue, i, a) {
selector = currentValue;
colWidth = 5;
if (!colWidth) {
colWidth = 1;
}
$(selector).css({
verticalAlign: 'bottom',
lineHeight: $(selector).height() + 'px'
});
var colQuantity = Math.ceil($(selector).width()/colWidth);
var cols = new Array(colQuantity);
for (var i = 0; i < cols.length; i++) {
var span = $('<span/>').appendTo(selector);
span.css({
verticalAlign: 'bottom',
display: 'inline-block',
fontSize: 0,
lineHeight: 0,
width: colWidth,
background: 'pink',
borderTop: '2px solid red'
});
}
}
function get_height(random, maxValue) {
if (random) {
return Math.round(maxValue * Math.random())
} else {
return maxValue/2;
};
}
function run_equalizer (selector) {
$(selector + ' span').each(function (i) {
var colHeight = get_height(k, $(selector).height());
$(this).height(colHeight);
});
}
equalizers = ["#eq_1 .equalizer", '#eq_2 .equalizer', '#eq_3 .equalizer'];
window.onload = function () {
equalizers.forEach(setEqualizer);
}
window.setInterval(function() {
equalizers.forEach(run_equalizer);
k = ! k;
},
timeout
);
</script>
</head>
<body>
<h1>Equalizers</h1>
<div id="eq_1" class="equalizer-wrapper">
<h2>First</h2>
<div class="equalizer small"></div>
</div>
<div id="eq_2" class="equalizer-wrapper">
<h2>Second</h2>
<div class="equalizer normal"></div>
</div>
<div id="eq_3" class="equalizer-wrapper">
<h2>Third</h2>
<div class="equalizer big"></div>
</div>
</body>
</html>