forked from Dogfalo/materialize
-
-
Notifications
You must be signed in to change notification settings - Fork 106
/
Copy pathscrollfire.html
107 lines (97 loc) · 3.18 KB
/
scrollfire.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<!doctype html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no">
<title>Documentation - Materialize</title>
<!-- Favicons -->
<link rel="apple-touch-icon-precomposed" href="../../docs/images/favicon/apple-touch-icon-152x152.png">
<meta name="msapplication-TileColor" content="#FFFFFF">
<meta name="msapplication-TileImage" content="images/favicon/mstile-144x144.png">
<link rel="icon" href="../../docs/images/favicon/favicon-32x32.png" sizes="32x32">
<!-- Android 5 Chrome Color -->
<meta name="theme-color" content="#EE6E73">
<link href="../../dist/css/materialize.css" type="text/css" rel="stylesheet" media="screen,projection">
<style>
body, html,
.section {
height: 100%;
}
.wrapper {
height: 100%;
width: 100%;
position: relative;
overflow: hidden;
}
.table-of-contents li a {
color: #fff;
}
.box {
width: 50%;
height: 50%;
transform: translateX(-100%);
background-color: #444;
transition: transform .3s;
}
#green .box, #red .box {
position: absolute;
right: 0;
transform: translateX(100%);
}
.scrolled .box,
#green.scrolled .box, #red.scrolled .box {
transform: translateX(0);
}
</style>
</head>
<body>
<div id="blue" class="section scrollspy blue">
<div class="wrapper">
<div class="box"></div>
</div>
</div>
<div id="green" class="section scrollspy green">
<div class="wrapper">
<div class="box"></div>
</div>
</div>
<div id="yellow" class="section scrollspy yellow">
<div class="wrapper">
<div class="box"></div>
</div>
</div>
<div id="red" class="section scrollSpy red">
<div class="wrapper">
<div class="box"></div>
</div>
</div>
<div class="stats" style="position: fixed; top: 50%; left: 50%; width: 100px; margin-left: -50px;">
<strong>scrollTop: </strong><span id="scrollTop">0</span>
</div>
<!-- Scripts -->
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="../../dist/js/materialize.js"></script>
<script type="text/javascript">
$( document ).ready(function() {
var options = [
{selector: '#blue', offset: 50, callback: function(el) {
$(el).addClass('scrolled');
} },
{selector: '#green', offset: 50, callback: function(el) {
$(el).addClass('scrolled');
} },
{selector: '#yellow', offset: 50, callback: function(el) {
$(el).addClass('scrolled');
} },
{selector: '#red', offset: 50, callback: function(el) {
$(el).addClass('scrolled');
} },
];
Materialize.scrollFire(options);
$(window).on('scroll', function() {
$('#scrollTop').text($(window).scrollTop());
});
});
</script>
</body>
</html>