-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
277 lines (245 loc) · 9.41 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Semi-sticky Navigation Plugin</title>
<link href='https://fonts.googleapis.com/css?family=Merriweather:300|Open+Sans:400,600' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="demo/prism.css">
<style media="screen">
* {
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
}
body {
padding: 0;
margin: 0;
font-family: 'Open Sans', sans-serif;
color: #555;
background-color: #fefdfc;
font-size: 18px;
}
p {
font-family: 'Merriweather', serif;
font-size: 1.125em;
line-height: 1.875;
}
a {
text-decoration: none;
border-bottom: solid 1px;
padding-bottom: 2px;
color: #555;
-webkit-transition: color .3s;
transition: color .3s;
}
a:hover {
color: #333;
}
.sans-serif {
font-family: 'Open Sans', sans-serif;
}
section {
padding: 40px;
}
.content {
margin-top: 114px;
}
.contained {
max-width: 37.5em;
}
.centered {
margin: 0 auto;
}
.clear {
clear: both;
}
.align-center {
text-align: center;
}
nav {
position: fixed;
top: 0;
left: 0;
width: 100%;
background-color: #2ec97b;
color: #fff;
}
nav a {
color: #fff;
text-decoration: none;
border-bottom: none;
}
nav a:hover {
color: #fff;
}
nav .nav-main {
padding: 10px 20px;
}
nav .nav-actions {
height: 40px;
line-height: 40px;
padding: 0 20px;
background-color: #30BB75;
color: #fff;
}
nav .nameplate {
float: left;
border: solid 2px #fff;
color: #fff;
padding: .375em .75em;
position: relative;
border-radius: 3px;
font-size: 1.5em;
line-height: 1.125;
font-family: 'Garamond', 'Adobe Garamond', 'Merriweather', serif;
}
nav ul {
float: right;
list-style: none;
margin: 0;
padding: 0;
}
nav ul li {
display: inline-block;
line-height: 50px;
padding: 0 10px;
}
nav .nav-actions li {
font-size: 12px;
line-height: 20px;
}
footer {
background-color: #333;
color: #676564;
font-size: .875em;
padding: 20px;
}
#log {
position: fixed;
bottom: 0;
right: 0;
background-color: #efeeea;
padding: 5px 10px;
font-size: .875em;
}
code {
padding: 3px 5px;
background-color: #efeeea;
color: #555;
margin: 0;
border-radius: 2px;
font-size: .875em;
}
pre code {
padding: 0;
background-color: transparent;
}
</style>
</head>
<body>
<nav>
<div class="nav-actions">
<ul>
<li><a href="https://github.com/wosephjeber" target="_blank">Find me on GitHub</a></li>
<li><a href="https://twitter.com/wosephjeber" target="_blank">Find me on Twitter</a></li>
<li><a href="http://wosephjeber.com" target="_blank">Read my blog</a></li>
</ul>
<div class="clear"></div>
</div>
<div class="nav-main">
<div class="nameplate">Joseph Weber</div>
<ul>
<li><a href="https://github.com/wosephjeber/semisticky" target="_blank">Source on GitHub</a></li>
</ul>
<div class="clear"></div>
</div>
</nav>
<div class="content">
<section>
<div class="contained centered">
<h1>Semi-sticky Navigation</h1>
<p>
This is a demonstration of my <span class="sans-serif">semisticky.js</span> jQuery plugin, which
lets you create a fixed navigation bar that shows and hides all or
part of itself based on scroll behavior. If that description is confusing
it's because I don't know what the proper term for this type of
interaction is. If you know a better term, please tweet me at
<a href="https://twitter.com/wosephjeber" href="blank">@wosephjeber</a>.
</p>
<p>
Basically, it allows you to create a fixed element at the top of the
window that hides all or part of itself when scrolling down and reveals
itself when scrolling up. In this demo, I've broken the nav into two
sections, hiding only the top section based on the scroll direction.
</p>
<p>
Here's the plugin code used on this page:
</p>
<pre><code class="language-javascript">
$('nav').semisticky({
offsetLimit: $('.nav-actions').outerHeight(),
onScroll: function(delta) {
$('#delta').html(delta);
$('#offset').html(this.currentOffsetAmount);
$('#state').html(this.state);
}
});
</code></pre>
<p>
I'm demonstrating the <code>onScroll()</code> callback by logging some
data to that <code>div</code> in the corner. With each scroll event,
the plugin calculates the change in scroll position, or <code>delta</code>.
If you're scrolling down, the <code>delta</code> is positive. If you're scrolling
up, the <code>delta</code> is negative.
</p>
<h2>And now for some filler text to make this page longer</h2>
<p>
Mumblecore Banksy Brooklyn 8-bit Vice. Semiotics Austin lomo you probably haven't heard of them ugh, scenester meditation Neutra banh mi master cleanse Carles migas disrupt. Next level drinking vinegar chia, try-hard scenester XOXO vegan post-ironic listicle +1 pug before they sold out. Health goth banh mi whatever, migas paleo Pinterest street art tousled. Trust fund Truffaut readymade quinoa, hoodie paleo cray heirloom lomo tattooed aesthetic flexitarian. Try-hard Godard hoodie, sartorial cornhole keffiyeh Bushwick Etsy art party retro swag post-ironic. Marfa food truck crucifix, health goth umami next level Shoreditch actually XOXO bespoke scenester heirloom McSweeney's selfies locavore.
</p>
<p>
Food truck actually Banksy, post-ironic kogi leggings 8-bit. Flexitarian occupy tofu American Apparel, normcore McSweeney's High Life. Four loko pickled cred stumptown vinyl. Pinterest Tumblr Helvetica, tattooed direct trade Vice vinyl Etsy. Pour-over mlkshk swag, freegan fingerstache food truck master cleanse aesthetic normcore artisan before they sold out Brooklyn. Meggings ugh Vice, wayfarers Echo Park viral PBR salvia blog church-key chambray. Lumbersexual DIY bicycle rights squid, single-origin coffee brunch raw denim plaid before they sold out irony.
</p>
<p>
Cold-pressed cronut tofu dreamcatcher, Pitchfork retro Pinterest literally jean shorts sartorial pork belly gluten-free mixtape quinoa. Carles ennui master cleanse butcher, salvia leggings viral readymade. Actually kale chips pork belly Marfa. Disrupt blog meggings Austin. Meggings iPhone flexitarian, mlkshk ennui Banksy Brooklyn mixtape Truffaut art party sriracha scenester hella Carles. DIY selvage hoodie, four loko occupy 3 wolf moon seitan twee bicycle rights wayfarers keffiyeh Thundercats Etsy taxidermy. Before they sold out normcore cred single-origin coffee meh cronut stumptown, Blue Bottle Vice pork belly quinoa Wes Anderson ethical next level.
</p>
<p>
Banjo hashtag Echo Park Williamsburg pickled, gentrify scenester. Aesthetic banjo Portland chillwave letterpress seitan selfies gluten-free, leggings mumblecore Etsy keffiyeh. Art party seitan sartorial deep v squid, 90's listicle. Mixtape selvage four loko, dreamcatcher Portland tattooed plaid kogi. Gluten-free cred sartorial YOLO keytar fixie. Lomo asymmetrical four loko Helvetica pork belly, forage four dollar toast post-ironic. Farm-to-table Williamsburg fanny pack, 3 wolf moon church-key cray selfies.
</p>
</div>
</section>
</div>
<footer>
<div class="contained centered align-center">
©2015 Joseph Weber
</div>
</footer>
<div id="log">
Delta: <span id="delta">0</span> px | Current offset: <span id="offset">0</span>px | State: <span id="state">fixed</span>
</div>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="src/semisticky.min.js"></script>
<script type="text/javascript">
// replaces < characters with < to allow syntax highlighter to
// display HTML code instead of browser parsing and rendering it as HTML
$('code').each(function() {
$(this).html($(this).html().replace(/</g, '<').replace(/>/g, '>').replace(/\$/g, '$'));
});
// suppress JS errors caused by console.log() on IE8 and 9
if (typeof console === 'undefined' || typeof console.log === 'undefined') {
window.console = {};
console.log = function() {};
}
</script>
<script type="text/javascript" src="demo/prism.js"></script>
<script>
$('nav').semisticky({
offsetLimit: $('.nav-actions').outerHeight(),
onScroll: function(delta) {
$('#delta').html(delta);
$('#offset').html(this.currentOffsetAmount);
$('#state').html(this.state);
}
});
</script>
</body>
</html>