-
Notifications
You must be signed in to change notification settings - Fork 10
/
test.html
126 lines (109 loc) · 3.26 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
117
118
119
120
121
122
123
124
125
126
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>hunt | stress test</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/4.0.0/normalize.min.css">
<style>
body {
color: #010120;
font-family: -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto, Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji', 'Segoe UI Symbol';
line-height: 1.65;
font-size: 17px;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.container {
max-width: 40rem;
margin: 0 auto;
padding: 0 1rem;
}
.excerpt {
color: #505060;
}
a {
color: #4242ef;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
#rows--wrapper {
padding: 2rem 0;
}
.row {
display: flex;
align-items: center;
justify-content: space-between;
}
.element {
background-image: linear-gradient(to right, #9090b8, #bdbdd6);
transition: transform .25s ease .025s;
width: 20%;
height: 128px;
}
.visible {
transform: scale(.6) rotate(45deg) translateZ(0);
}
</style>
</head>
<body>
<header>
<div class="container">
<h1>hunt</h1>
<p class="excerpt">Minimal library to observe nodes entering and leaving the viewport. Library written by <a
href="//jeremenichelli.io">Jeremias Menichelli</a> and contributors.</p>
<p>Stress test observing multiple elements being animated as they become visible.</p>
</div>
</header>
<main>
<div id="rows--wrapper" class="container"></div>
</main>
<!-- PREPARE OBSERVED ELEMENTS -->
<script>
var wrapper = document.getElementById('rows--wrapper');
for (var i = 25; --i > 0;) {
wrapper.innerHTML += `<div class="row">
<div class="element"></div>
<div class="element"></div>
<div class="element"></div>
<div class="element"></div>
</div>`;
}
</script>
<!-- LOAD HUNT LIBRARY -->
<script src="https://unpkg.com/huntjs/dist/hunt.umd.js"></script>
<!-- OBSERVE TEST ELEMENTS -->
<script>
var observer = new Hunt(document.getElementsByClassName('element'), {
enter: function(el) {
el.classList.add('visible');
},
leave: function(el) {
el.classList.remove('visible');
},
persist: true
});
</script>
<!-- STATS -->
<script>
(function() {
var script = document.createElement('script');
script.async = true;
script.onload = function() {
var stats = new Stats();
stats.dom.style = 'right:1em;top:1em;position:fixed';
document.body.appendChild(stats.dom);
requestAnimationFrame(function loop(){
stats.update();
requestAnimationFrame(loop);
});
};
script.src='https://rawgit.com/mrdoob/stats.js/master/build/stats.min.js';
document.head.appendChild(script);
})();
</script>
</body>
</html>