forked from rikschennink/fitty
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.html
101 lines (80 loc) · 2.71 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
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<title>Fitty Test Page</title>
<style>
.pre-style .fit {
display:inline-block;
white-space:nowrap;
}
.fixed {
border-top:2px solid silver;
width:20em;
}
p {
margin:0;
}
</style>
</head>
<body>
<main>
<div class="pre-style fixed">
<p class="fit" style="color:red;">Integer</p>
<p class="fit" style="color:green;">Lorem ipsum dolor sit.</p>
<p class="fit" style="color:blue;">consectetur adipiscing elit.</p>
<p class="fit" style="color:purple;">aecenas elementum purus nec felis pellentesque, eget volutpat mauris vestibulum.</p>
</div>
<div class="pre-style">
<p class="fit" style="color:red;">Integer</p>
<p class="fit" style="color:green;">Lorem ipsum dolor sit.</p>
<p class="fit" style="color:blue;">consectetur adipiscing elit.</p>
<p class="fit" style="color:purple;">aecenas elementum purus nec felis pellentesque, eget volutpat mauris vestibulum.</p>
</div>
<div class="fixed">
<p class="fit" style="color:red;">Integer</p>
<p class="fit" style="color:green;">Lorem ipsum dolor sit.</p>
<p class="fit" style="color:blue;">consectetur adipiscing elit.</p>
<p class="fit" style="color:purple;">aecenas elementum purus nec felis pellentesque, eget volutpat mauris vestibulum.</p>
</div>
<div>
<p class="fit" style="color:red;">Integer</p>
<p class="fit" style="color:green;">Lorem ipsum dolor sit.</p>
<p class="fit" style="color:blue;">consectetur adipiscing elit.</p>
<p class="fit" style="color:purple;">aecenas elementum purus nec felis pellentesque, eget volutpat mauris vestibulum.</p>
</div>
</main>
<script src="dist/fitty.min.js"></script>
<script>
var fitties = [];
// is delayed a bit so it's clear in performance timeline when fitty kicks in
setTimeout(function(){
fitties = fitty('.fit');
console.log('fitties created');
}, 1000);
// stop responding to resize after 3 seconds
setTimeout(function(){
fitties.forEach(function(fitty) {
fitty.freeze();
});
console.log('fitties freezed');
}, 3000);
// start responding to resize after 5 seconds
setTimeout(function(){
fitties.forEach(function(fitty) {
fitty.unfreeze();
})
console.log('fitties unfreezed');
}, 5000);
// clean up after 5 seconds
setTimeout(function(){
var fitty;
while(fitty = fitties.pop()) {
fitty.unsubscribe();
}
console.log('fitties unsubscribed');
}, 7000);
</script>
</body>
</html>