-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspatial-demos.html
49 lines (44 loc) · 1 KB
/
spatial-demos.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
<!DOCTYPE html>
<script src="intersectionobserver.js"></script>
<script src="lazy-elements.js"></script>
<style>
div, x-optional, x-deferred {
height: 50px;
margin: 10px;
background-color: papayawhip;
color: salmon
}
x-optional {
background-color: pink;
}
x-deferred {
background-color: lightblue;
}
#item-5 {
background-color: red !important;
}
</style>
<script>
function dumpDivs() {
for (var i = 0; i < 20; i++) {
document.write('<div>' + (i + 1) + '</div>');
}
}
function dumpOptional() {
document.write('<x-optional>optional</x-optional><x-deferred>deferred</x-deferred>');
}
for (var i = 0; i < 10; i++) {
dumpDivs();
dumpOptional();
}
// var item = document.getElementById('item-20');
// function onIntersect(records) {
// records.forEach(function(record) {
// console.log(record);
// });
// }
// var intersectionObserver = new IntersectionObserver({
// callback: onIntersect,
// });
// intersectionObserver.observe(item);
</script>