forked from DanielRapp/doppler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.html
34 lines (34 loc) · 922 Bytes
/
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
<!doctype html>
<html>
<head>
<style>
#box {
background-color: #000;
width: 100px;
height: 100px;
margin-top: 100px;
margin-left: auto;
margin-right: auto;
}
</style>
</head>
<body>
<div id="box"></div>
<script src="doppler.js"></script>
<script>
window.addEventListener('load', function() {
window.doppler.init(function(bandwidth) {
var threshold = 4;
if (bandwidth.left > threshold || bandwidth.right > threshold) {
var scale = 10;
var baseSize = 100;
var diff = bandwidth.left - bandwidth.right;
var dimension = (baseSize + scale*diff) + 'px';
document.getElementById('box').style.width = dimension;
document.getElementById('box').style.height = dimension;
}
});
});
</script>
</body>
</html>