This repository was archived by the owner on Aug 14, 2021. It is now read-only.
forked from cobbweb/jquery.scrollwatch
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
65 lines (52 loc) · 1.47 KB
/
index.html
File metadata and controls
65 lines (52 loc) · 1.47 KB
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
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>jQuery Scroll Watcher</title>
<script src="bower_components/jquery/jquery.js"></script>
<script src="bower_components/lodash/lodash.js"></script>
<script src="src/jquery.scrollwatch.js"></script>
<style>
html, body {
margin: 0;
padding: 0;
font-family: 'Helvetica Neue', Helvetica, sans-serif;
}
.whitespace {
height: 2000px;
}
.box {
margin: 0 auto;
padding: 56px 24px;
width: 940px;
border: 1px solid #d5d5d5;
background-color: #f5f5f5;
}
#huge-box {
height: 2000px;
}
</style>
</head>
<body>
<div class="whitespace"></div>
<div id="testing" class="box">Testing div that all day way off the page</div>
<div class="whitespace"></div>
<div id="huge-box" class="box">
Huge box
</div>
<div class="whitespace"></div>
<script>
$('#testing')
.css('height', document.documentElement.clientHeight + 'px')
.scrollWatch()
.on('scrollin', function(e) { console.log('in', e.direction); })
.on('scrollout', function(e) { console.log('out', e.direction); })
.handleScroll();
$('#huge-box').scrollWatch()
.on('scrollin', function(e) { console.log('huge in', e.direction); })
.on('scrollout', function(e) { console.log('huge out', e.direction); })
.on('scroll', function(e) { console.log('huge visibility', e.visibility); })
.handleScroll();
</script>
</body>
</html>