-
Notifications
You must be signed in to change notification settings - Fork 45
/
dynamic-height.html
85 lines (73 loc) · 1.69 KB
/
dynamic-height.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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Hyper List Demo</title>
<style>
body, html {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
min-height: 100%;
min-width: 100%;
text-align: center;
}
body {
overflow: hidden;
}
@media
only screen and (-webkit-min-device-pixel-ratio : 1.5),
only screen and (min-device-pixel-ratio : 1.5) {
.container {
width: 100%;
height: 100%;
min-height: 100%;
}
}
.vrow {
width: 100%;
color: #000;
margin: 0;
padding-top: 10px;
padding-bottom: 10px;
}
.vrow p {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
margin: 0;
color: #5b5b5b;
}
</style>
</head>
<body>
<script type="text/javascript" src="../dist/hyperlist.js"></script>
<script>
var container = document.createElement('div');
var config = {
height: window.innerHeight,
itemHeight: 50,
total: 1000,
// Set to true to put into 'chat mode'.
reverse: false,
scrollerTagName: 'div',
generate(row) {
var newHeight = Math.floor(Math.random() * 50) + 50;
var el = Object.assign(document.createElement('div'), {
innerHTML: `<p>ITEM ${row}</p>`,
});
return {element: el, height: newHeight};
}
};
var list = HyperList.create(container, config);
window.onresize = e => {
config.height = window.innerHeight;
list.refresh(container, config);
};
container.classList.add('container');
document.body.appendChild(container)
</script>
</body>
</html>