forked from joshwnj/react-visibility-sensor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
85 lines (75 loc) · 1.98 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
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>
<head>
<style>
body {
min-height: 1000px;
}
#example {
height: 100px;
}
.msg {
position: fixed;
top: 20px;
left: 10px;
}
.sensor {
display: block;
width: 50px;
height: 50px;
background: red;
}
#example-container {
width: 200px;
height: 200px;
border: 1px solid #000;
overflow: auto;
position: relative;
}
#example-container .inner {
width: 800px;
height: 800px;
}
#example-container .sensor {
position: absolute;
left: 400px;
top: 400px;
}
#example-container .msg {
top: 40px;
}
#example-container .msg:before {
content: 'Contained ';
}
#info {
position: fixed;
z-index: 1;
top: 10px;
right: 10px;
width: 400px;
}
#foreground {
position: relative;
z-index: 2;
background: #FFF;
width: 300px;
}
</style>
</head>
<body>
<div id="info">
<p>In this example, the first element's visibility will change as you scroll the page. The second element uses the `containment` prop to tell whether it is within the visible part of the container. Scroll around to see it change.</p>
<p>Note that the "Contained Element" in this example is also using the <code>`partialVisibility`</code> prop. So it will be considered "visible" if even part of it is within the viewport.</p>
</div>
<div id="foreground">
<div id="example"></div>
<div id="example-container">
<div class="inner"></div>
</div>
</div>
<script src="https://unpkg.com/[email protected]/dist/react.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/react-dom.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/visibility-sensor.min.js"></script>
<script src="./main.js"></script>
</body>
</html>