-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
75 lines (69 loc) · 2.81 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<title>threshold - manages page width change</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="dist/threshold.css" rel="stylesheet">
<link href="dist/demo.css" rel="stylesheet">
</head>
<body>
<header class="width-full">
<div class="width-fixed">
<span class="show-x-large">x-large</span>
<span class="show-large">large</span>
<span class="show-medium">medium</span>
<span class="show-small">small</span>
<span class="show-x-small">x-small</span>
<span class="show-mobile">mobile</span>
</div>
</header>
<div class="width-full">
<div class="width-fixed" id="console">
 
</div>
</div>
<footer class="width-full">
<div class="width-fixed">
 
</div>
</footer>
<script type="text/javascript" src="//code.jquery.com/jquery-2.1.4.min.js"></script>
<script>!window.jQuery && document.write('<script src="bower_components/jquery/dist/jquery.min.js"><\/script>')</script>
<script src="dist/threshold.js"></script>
<script>
$(function() {
threshold({
ranges: {
'x-large': ['1600px', -1], // '1480px'
'large': ['1440px', '1599px'], // '1360px'
'medium': ['1280px', '1439px'], // '1220px'
'small': ['960px', '1279px'], // '920px'
'x-small': ['760px', '959px'], // '740px',
'mobile': [-1,'759px'], // '100%',
}
});
$(window).data('threshold').after('mobile', function() {
$('#console').append('<p>[mobile]<br>callback after switch to a specific range: < 760px</p>');
});
$(window).data('threshold').after('x-small', function() {
$('#console').append('<p>[x-small]<br>callback after switch to a specific range: >= 760px and < 960px (a first callback)</p>');
});
$(window).data('threshold').after('x-small', function() {
$('#console').append('<p>[x-small]<br>other callback after switch to a specific range: >= 760px and < 960px (a second callback)</p>');
});
$(window).data('threshold').after(['small', 'medium'], function() {
$('#console').append('<p>[small] AND [medium]<br>callback after switch to a specific range: >= 960px and < 1280px AND >= 1280px and < 1440px</p>');
});
$(window).data('threshold').after('large|x-large', function() {
$('#console').append('<p>[large] OR [x-large]<br>callback after switch to a specific range: >= 1440px ie >= 1440px and < 1600px OR >= 1600px</p>');
});
$(window).data('threshold').after('all', function() {
$('#console').append('<p>[all]<br>callback when width range switches to another</p>');
$('#console').children('p').delay(3000).fadeTo(1000, 0, function(){
$(this).remove();
})
});
});
</script>
</body>
</html>