forked from Aerolab/midnight.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
313 lines (230 loc) · 10.6 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Midnight.js - Switch fixed headers on the fly</title>
<meta name="description" content="Midnight.js is a jQuery plugin that lets you sublty change your headers to make them match the content as you scroll." />
<meta name="keywords" content="js, jquery, scroll, plugin, animation" />
<meta name="robots" content="INDEX, FOLLOW" />
<meta name="author" content="Aerolab" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui" />
<!-- Facebook Stuff -->
<meta property="og:type" content="website" />
<meta property="og:site_name" content="Midnight.js" />
<meta property="og:title" content="Midnight.js - Switch fixed headers on the fly" />
<meta property="og:description" content="Midnight.js is a jQuery plugin that lets you sublty change your headers to make them match the content as you scroll." />
<meta property="og:image" content="http://aerolab.github.io/midnight.js/assets/images/midnight-facebook.png" />
<meta property="og:url" content="http://aerolab.github.io/midnight.js" />
<meta property="fb:app_id" content="344819049029949" />
<!-- Twitter Stuff -->
<meta property="twitter:card" content="summary" />
<meta property="twitter:site" content="@aerolab" />
<meta property="twitter:title" content="Midnight.js - Switch fixed headers on the fly" />
<meta property="twitter:description" content="Midnight.js is a jQuery plugin that lets you sublty change your headers to make them match the content as you scroll." />
<meta property="twitter:image" content="http://aerolab.github.io/midnight.js/assets/images/midnight-twitter.png" />
<meta property="twitter:url" content="http://aerolab.github.io/midnight.js" />
<link rel="icon" href="assets/images/favicon.ico" type="image/icon" />
<link rel="shortcut icon" href="assets/images/favicon.ico" type="image/x-icon" />
<meta name="X-UA-Compatible" content="IE=edge" />
<meta name="SKYPE_TOOLBAR" content="SKYPE_TOOLBAR_PARSER_COMPATIBLE" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<link href="http://fonts.googleapis.com/css?family=Lato:400,300italic,400bold" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="assets/css/normalize.css" />
<link rel="stylesheet" href="assets/css/animate.css" />
<link rel="stylesheet" href="assets/css/styles.css" />
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-21195039-3', 'aerolab.github.io');
ga('require', 'displayfeatures');
ga('require', 'linkid', 'linkid.js');
ga('send', 'pageview');
</script>
</head>
<body>
<!-- Our super awesome changing header! -->
<nav class="fixed">
<div class="midnightHeader default">
<div class="logo-holder">
<a class="logo"><span class="screenreader"></span></a>
</div>
</div>
</nav>
<div class="top-links" data-midnight="white">
<a class="button" href="https://aerolab.github.io/midnight.js/midnight.jquery.min.js" download>Download</a>
<a class="button button-github" href="https://github.com/Aerolab/midnight.js" target="_blank">Fork on GitHub</a>
</div>
<div class="first-background" data-midnight="white">
<!-- Hi! -->
</div>
<header data-midnight="black">
<div class="container">
<h1 class="wow fadeInUp">Midnight.js lets you switch fixed headers on the fly</h1>
<p class="wow fadeInUp">Scroll to try it out!</p>
<div class="scroll-prompt wow fadeInUp"></div>
<figure id="space-island">
<img class="wow fadeInUp" src="assets/css/images/space-island.jpg" />
</figure>
</div>
</header>
<section class="step step-one" data-midnight="blue">
<div class="container">
<div class="instructions wow fadeInLeft">
<h2>The Header</h2>
<p>Create your fixed nav (or header) as you typically would.</p>
<p>You can use whatever markup suits you, just make sure the header works well with <em>position:fixed</em>.</p>
</div>
<pre class="line-numbers wow fadeInRight"><code class="language-markup"><!-- Your Fixed Nav -->
<nav class="fixed">
<a class="logo">Logo</a>
</nav></code></pre>
</div>
</section>
<section class="step step-two" data-midnight="light">
<div class="container">
<div class="instructions wow fadeInLeft">
<h2>The Sections</h2>
<p>After that, take any sections of your page that need a different nav and add <em>data-midnight="your-class"</em> to it, where <em>.your-class</em> is the class you are going to use to style that header.</p>
<p>If you don't use the property or just leave it blank, the <em>.default</em> class will be used for that section.</p>
</div>
<pre class="line-numbers wow fadeInRight"><code class="language-markup"><section data-midnight="white">
<h1>Use a white nav here</h1>
</section>
<div data-midnight="blue">
<h1>And a blue nav here</h1>
</div>
<footer>
<h1>This will just use the default header</h1>
</footer></code></pre>
</div>
</section>
<section class="step step-three" data-midnight="dark">
<div class="container">
<div class="instructions wow fadeInLeft">
<h2>Styling your headers</h2>
<p>You can style it in your css using the class <em>.midnightHeader.your-class</em>.</p>
<p>Use whatever CSS or markup you like for each one. They will be switched automatically when necessary.</p>
</div>
<pre class="line-numbers wow fadeInRight"><code class="language-css">.midnightHeader.default {
background: none;
color: black;
}
.midnightHeader.white {
background: white;
color: black;
}
.midnightHeader.blue {
background: blue;
color: white;
}</code></pre>
</div>
</section>
<section class="step step-four" data-midnight="lighter">
<div class="container">
<div class="instructions wow fadeInLeft">
<h2>The jQuery Plugin</h2>
<p>To make everything work, just load midnight (and jQuery) and initialize it. We take care of the rest.</p>
</div>
<pre class="line-numbers wow fadeInRight"><code class="language-markup"><script src="midnight.jquery.min.js"></script>
<script>
// Start midnight
$(document).ready(function(){
// Change this to the correct selector.
$('nav.fixed').midnight();
});
</script></code></pre>
</div>
</section>
<section class="step step-five full-height" data-midnight="white">
<div class="container">
<div class="instructions wow fadeInLeft">
<h2>Further customization</h2>
<p>Want to use custom markup for each header?</p>
<p>You just need to add a div with the class <em>.midnightHeader.default</em> inside your header, as well as any other custom headers you want.</p>
<p>For instance the "butterflies" section will use the .midnightHeader.butterflies header, and any other ones will just use the markup from .midnightHeader.default.</p>
</div>
<pre class="line-numbers wow fadeInRight"><code class="language-markup"><nav class="fixed">
<!-- Your standard header -->
<div class="midnightHeader default">
<a class="logo">Logo</a>
</div>
<!-- A header with butterflies -->
<div class="midnightHeader butterflies">
<a class="logo">Logo</a>
<span class="a-butterfly"></span>
<span class="another-butterfly"></span>
</div>
</nav></code></pre>
</div>
</section>
<footer class="footer" data-midnight="full">
<div class="illustration-city">
<div class="container">
<div class="buttons wow fadeIn">
<a class="button" href="https://aerolab.github.io/midnight.js/midnight.jquery.min.js" download>Download</a>
<a class="button" href="https://github.com/Aerolab/midnight.js" target="_blank"><i class="icon-github"></i> Fork on GitHub</a>
</div>
</div>
<div class="signature">
<a href="http://aerolab.co" target="_blank" class="signature-aerolab"><span class="screenreader">by Aerolab</span></a>
</div>
</div>
</footer>
<script src="assets/js/jquery-1.11.1.min.js"></script>
<script src="assets/js/sscr.min.js"></script>
<script src="assets/js/prism.js"></script>
<script src="assets/js/wow.min.js"></script>
<script src="assets/js/viewport-units-buggyfill.js"></script>
<script src="midnight.jquery.min.js"></script>
<script>
$(document).ready(function(){
// vh fix for iOS7 (Not that it works well on that anyway)
viewportUnitsBuggyfill.init();
$(window).resize(function(){
viewportUnitsBuggyfill.refresh();
});
// Start Midnight!
$('nav.fixed').midnight();
// Start wow.js
new WOW().init();
// The island disappears when the logo moves on top of it
var $island = $('#space-island');
var islandTop = $island.offset().top;
var windowHeight = $(window).height();
$(window).resize(function(){
islandTop = $island.offset().top;
windowHeight = $(window).height();
});
$(document).scroll(function(){
var scrollTop = window.pageYOffset || document.documentElement.scrollTop;
var minScrollTop = islandTop - windowHeight * 0.4;
var maxScrollTop = islandTop;
// Opacity goes from 1.0 at the bottom 2/3 of the screen to 0.4 at the top
if( scrollTop <= islandTop*2 ) {
var targetOpacity = 1.0;
var minOpacity = 0.4;
if( scrollTop > minScrollTop && scrollTop < maxScrollTop ) {
targetOpacity = ((maxScrollTop - scrollTop) / (maxScrollTop - minScrollTop)) * (1.0 - minOpacity) + minOpacity;
}
else if( scrollTop > maxScrollTop ) {
targetOpacity = minOpacity;
}
else if( scrollTop < minScrollTop ) {
targetOpacity = 1.0;
}
$island.css('opacity', targetOpacity);
}
});
$('.scroll-prompt').click(function(event){
event.preventDefault();
$('html, body').animate({
scrollTop: $("section.step-one").offset().top - $('nav').height() * 0.5
}, 1000, 'swing');
});
$(window).trigger('resize');
});
</script>
</body>
</html>