-
Notifications
You must be signed in to change notification settings - Fork 0
/
Index.html
41 lines (36 loc) · 1.17 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
<!DOCTYPE html>
<html>
<head>
<title>UChicago Marketplace</title>
<script src="main.js" type="text/javascript"></script>
</head>
<body style="background-color:#f5f5f5">
<div id="root"></div>
<div id="bottom"></div>
<script type="text/javascript">
// Set up Elm runtime
var root = document.getElementById("root");
var app = Elm.embed(Elm.Main, root, {lastItemVisible : false});
// Infinite Scroll
function isElementInViewport (el) {
var rect = el.getBoundingClientRect();
return (
rect.top >= 0 &&
rect.left >= 0 &&
rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && /*or $(window).height() */
rect.right <= (window.innerWidth || document.documentElement.clientWidth) /*or $(window).width() */
);
}
window.onscroll = function () {
var lastItem = document.getElementById("bottom");
if (isElementInViewport(lastItem)) {
app.ports.lastItemVisible.send(true);
}
else {
app.ports.lastItemVisible.send(false);
}
};
// Masonry
</script>
</body>
</html>