forked from imakewebthings/waypoints
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
652 lines (544 loc) · 33.3 KB
/
index.html
File metadata and controls
652 lines (544 loc) · 33.3 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
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
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>jQuery Waypoints</title>
<meta name="viewport" content="width=640">
<link href='http://fonts.googleapis.com/css?family=Ubuntu+Mono|Lato:400,700|PT+Serif:700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="nav">
<h1>jQuery Waypoints</h1>
<p class="version">v2.0.4</p>
<ul>
<li><a class="nav-about" href="#about">About</a></li>
<li><a class="nav-started" href="#get-started">Get Started</a></li>
<li><a class="nav-shortcuts" href="#shortcuts-examples">Shortcuts & Examples</a></li>
<li><a class="nav-docs" href="#docs">Docs</a></li>
</ul>
</div>
<div id="about" class="panel about">
<div class="inner">
<div class="summary">
<p>Waypoints is a jQuery plugin that makes it easy to execute a function whenever you scroll to an element.</p>
<pre><code><span class="fn">$</span>(<span class="str">'.thing'</span>).<span class="fn">waypoint</span>(<span class="kw">function</span>(direction) {
<span class="fn">alert</span>(<span class="str">'Top of thing hit top of viewport.'</span>);
});</code></pre>
<ul>
<li><a href="https://github.com/imakewebthings/jquery-waypoints/zipball/latest" class="icon about-download">Download</a></li>
<li><a href="http://github.com/imakewebthings/jquery-waypoints" class="icon about-github">GitHub</a></li>
<li><a href="test/" class="icon about-tests">Tests</a></li>
<li><a href="https://github.com/imakewebthings/jquery-waypoints/blob/master/licenses.txt" class="icon about-licenses">Licenses</a></li>
</ul>
</div>
<div class="new-in-2">
<h2>New in 2.0</h2>
<ul>
<li>
<h3 class="icon new-horizontals">Horizontals</h3>
<p>Waypoints can now be created for horizontal scrolling. Just pass <code>horizontal:true</code> to your waypoint options.</p>
</li>
<li>
<h3 class="icon new-multiples">Multiples</h3>
<p>One HTML element can now have multiple Waypoints attached to it, each with its own <code>offset</code> and handler.</p>
</li>
<li>
<h3 class="icon new-shortcuts">Shortcuts</h3>
<p>The most common uses for Waypoints are now even easier to implement with <a href="#shortcuts-examples">shortcut methods</a>.</p>
</li>
<li>
<h3 class="icon new-api">Revised API</h3>
<p>A new handler signature, added introspection methods, and more. Be sure to check the new <a href="#docs">docs</a> and the <a href="https://github.com/imakewebthings/jquery-waypoints/blob/master/CHANGELOG.md">changelog</a>.</p>
</li>
</ul>
</div>
</div>
</div>
<div id="get-started" class="panel get-started">
<div class="inner">
<div class="started-section">
<p>First thing's first, to get started with Waypoints, <a href="https://github.com/imakewebthings/jquery-waypoints/zipball/latest">download the plugin</a> and include it after you've included jQuery.</p>
<pre><code><<span class="fn">script</span> <span class="kw">src</span>=<span class="str">"/path/to/jquery.min.js"</span>><<span class="fn">/script</span>>
<<span class="fn">script</span> <span class="kw">src</span>=<span class="str">"/path/to/waypoints.min.js"</span>><<span class="fn">/script</span>></code></pre>
<p>You'll now have access to the <code>.waypoint</code> method on your jQuery objects.</p>
</div>
<div class="started-section">
<p>The simplest way to use Waypoints is to call <code>.waypoint</code> and pass in a function.</p>
<pre id="example-basic"><code><span class="fn">$</span>(<span class="str">'#example-basic'</span>).<span class="fn">waypoint</span>(<span class="kw">function</span>() {
<span class="fn">notify</span>(<span class="str">'Basic example callback triggered.'</span>);
});</code></pre>
<p>This example causes a notification whenever the top of <code>#example-basic</code> hits the top of the viewport. The callback triggers when you pass this point both scrolling up and scrolling down.</p>
</div>
<div class="started-section">
<p>More often than not we want to perform different actions depending on which direction the user is scrolling. Waypoints passes this direction as a parameter to the callback function.</p>
<pre id="example-direction"><code><span class="fn">$</span>(<span class="str">'#example-direction'</span>).<span class="fn">waypoint</span>(<span class="kw">function</span>(direction) {
<span class="fn">notify</span>(<span class="str">'Direction example triggered scrolling '</span> + direction);
});</code></pre>
<p>Here the notification reads "Direction example triggered scrolling down" or "Direction example triggered scrolling up".</p>
</div>
<div class="started-section">
<p>What if you want your waypoint to trigger in a location other than when the top of your element hits the top of the viewport? The <code>waypoint</code> function takes a second argument, an options object. One of the most useful options is <code>offset</code>, which tells Waypoints how far from the top of the window the callback should fire. This can be expressed in pixels…</p>
<pre id="example-offset-pixels"><code><span class="fn">$</span>(<span class="str">'#example-offset-pixels'</span>).<span class="fn">waypoint</span>(<span class="kw">function</span>() {
<span class="fn">notify</span>(<span class="str">'100 pixels from the top'</span>);
}, { <span class="key">offset</span>: 100 });</code></pre>
<p>…as a percentage of the viewport's height…</p>
<pre id="example-offset-percent"><code><span class="fn">$</span>(<span class="str">'#example-offset-percent'</span>).<span class="fn">waypoint</span>(<span class="kw">function</span>() {
<span class="fn">notify</span>(<span class="str">'25% from the top'</span>);
}, { <span class="key">offset</span>: <span class="str">'25%'</span> });</code></pre>
<p>…or as a function. The function needs to return a number. The following example will fire when the bottom of the element hits the top of the viewport.</p>
<pre id="example-offset-function"><code><span class="fn">$</span>(<span class="str">'#example-offset-function'</span>).<span class="fn">waypoint</span>(<span class="kw">function</span>() {
<span class="fn">notify</span>(<span class="str">'Element bottom hit window top'</span>);
}, {
<span class="key">offset</span>: <span class="kw">function</span>() {
<span class="kw">return</span> -<span class="fn">$</span>(<span class="kw">this</span>).<span class="fn">height</span>();
}
});</code></pre>
</div>
<div class="started-section">
<p>Let's say you have a <code>div</code> with <code>overflow:scroll</code>, and you want a waypoint inside of this scrollable element. The <code>context</code> option lets you do this. Scroll the box below.</p>
<div class="example-scroll-div">
<pre id="example-context"><code><span class="fn">$</span>(<span class="str">'#example-context'</span>).<span class="fn">waypoint</span>(<span class="kw">function</span>() {
<span class="fn">notify</span>(<span class="str">'Hit top of context'</span>);
}, { <span class="key">context</span>: <span class="str">'.example-scroll-div'</span> });</code></pre>
</div>
</div>
<div class="started-section">
<p>Not all sites scroll vertically. You can create a waypoint on the horizontal axis with the <code>horizontal</code> option. This project page uses horizontal waypoints when the user navigates between high-level sections.</p>
<pre><code><span class="fn">$</span>(<span class="str">'.panel'</span>).<span class="fn">waypoint</span>(<span class="kw">function</span>(direction) {
$body.<span class="fn">toggleClass</span>(<span class="kw">this</span>.id + <span class="str">'-visible'</span>, direction === <span class="str">'right'</span>);
}, {
<span class="key">offset</span>: <span class="str">'50%'</span>,
<span class="key">horizontal</span>: <span class="kw">true</span>
});</code></pre>
<p>As you can see, when <code>horizontal</code> is set to true the <code>direction</code> passed to the callback changes from "down" and "up" to "right" and "left".</p>
</div>
<div class="started-section">
<p>You can also create multiple waypoints on the same HTML element. Each waypoint can have its own options. The horizontal example above isn't the only waypoint created on the <code>.panel</code> elements.</p>
<pre><code><span class="fn">$</span>(<span class="str">'.panel'</span>).<span class="fn">waypoint</span>(<span class="kw">function</span>(direction) {
$body.<span class="fn">toggleClass</span>(<span class="kw">this</span>.id + <span class="str">'-visible'</span>, direction === <span class="str">'left'</span>);
}, {
<span class="key">offset</span>: <span class="str">'-50%'</span>,
<span class="key">horizontal</span>: <span class="kw">true</span>
});</code></pre>
</div>
<div class="started-section">
<p>CoffeeScript authors may find passing a function followed by an options object to be a bit clumsy. There is another way to pass the waypoints callback, using the <code>handler</code> option. If you provide a <code>handler</code> option, you only need to pass the options object.</p>
<pre id="example-handler"><code><span class="cm">/* In JavaScript */</span>
<span class="fn">$</span>(<span class="str">'#example-handler'</span>).<span class="fn">waypoint</span>({
<span class="key">handler</span>: <span class="kw">function</span>() {
<span class="fn">notify</span>(<span class="str">'Handler option used'</span>);
},
<span class="key">offset</span>: <span class="str">'50%'</span>
});
<span class="cm"># In CoffeeScript</span>
<span class="fn">$</span>(<span class="str">'#example-handler'</span>).<span class="fn">waypoint</span>
<span class="key">handler</span>: <span class="kw">-></span>
<span class="fn">notify</span> <span class="str">'Handler option used'</span>
<span class="key">offset</span>: <span class="str">'50%'</span></code></pre>
</div>
<div class="started-section">
<p>If you've got these basics under control, take a look at the <a href="#docs">docs</a> for more information on all of the options and methods available in Waypoints.</p>
<p>If you're looking to implement one of a number of common scroll-based UI patterns, give the <a href="#shortcuts-examples">shortcuts</a> section a try.</p>
</div>
</div>
</div>
<div id="shortcuts-examples" class="panel shortcuts-examples">
<div class="inner">
<div class="shortcuts">
<h2>Shortcuts</h2>
<p>jQuery Waypoints extensions that simplify some common UI patterns.</p>
<a href="shortcuts/sticky-elements" class="icon shortcut-sticky">Sticky Elements</a>
<a href="shortcuts/infinite-scroll" class="icon shortcut-infinite">Infinite Scroll</a>
</div>
<div class="examples">
<h2>Examples</h2>
<p>Other custom uses of Waypoints.</p>
<a href="examples/dial-controls" class="icon example-dials">Dial Controls</a>
<a href="examples/scroll-analytics" class="icon example-analytics">Scroll Analytics</a>
</div>
</div>
</div>
<div id="docs" class="panel docs">
<div class="inner">
<div class="docs-nav-wrapper">
<ul class="docs-nav">
<li>
<a href="#doc-waypoint">.waypoint</a>
<ul>
<li><a href="#doc-options">default options</a></li>
<li><a href="#doc-disable">disable</a></li>
<li><a href="#doc-enable">enable</a></li>
<li><a href="#doc-destroy">destroy</a></li>
<li><a href="#doc-prev">prev</a></li>
<li><a href="#doc-next">next</a></li>
</ul>
</li>
<li>
<a href="#doc-waypoints">$.waypoints</a>
<ul>
<li><a href="#doc-refresh">refresh</a></li>
<li><a href="#doc-viewport-height">viewportHeight</a></li>
<li><a href="#doc-above">above</a></li>
<li><a href="#doc-below">below</a></li>
<li><a href="#doc-left">left</a></li>
<li><a href="#doc-right">right</a></li>
<li><a href="#doc-disable-all">disable</a></li>
<li><a href="#doc-enable-all">enable</a></li>
<li><a href="#doc-destroy-all">destroy</a></li>
<li><a href="#doc-extend">extendFn</a></li>
</ul>
</li>
</ul>
</div>
<div id="doc-waypoint" class="doc-section">
<h2>.waypoint([callback], [options])</h2>
<ul class="params">
<li>
<h3>callback</h3>
<dl>
<dt>type</dt>
<dd>function, optional</dd>
</dl>
</li>
<li>
<h3>options</h3>
<dl>
<dt>type</dt>
<dd>object, optional</dd>
</dl>
</li>
</ul>
<p>Calling the <code>waypoint</code> function on a set of elements registers them as waypoints. You can pass in a callback function…</p>
<pre><code><span class="fn">$</span>(<span class="str">'.thing'</span>).<span class="fn">waypoint</span>(<span class="kw">function</span>(direction) {
<span class="cm">// do stuff</span>
});</code></pre>
<p>…an options object…</p>
<pre><code><span class="fn">$</span>(<span class="str">'.thing'</span>).<span class="fn">waypoint</span>({
<span class="key">handler</span>: <span class="kw">function</span>(direction) {
<span class="cm">// do stuff</span>
}
});</code></pre>
<p>…or both…</p>
<pre><code><span class="fn">$</span>(<span class="str">'.thing'</span>).<span class="fn">waypoint</span>(<span class="kw">function</span>(direction) {
<span class="kw">// do stuff</span>
}, { <span class="key">offset</span>: 50 })</code></pre>
<p>…but you must pass something. Attempting to call <code>waypoint</code> without parameters or without a callback function will result in an error.</p>
<pre><code><span class="fn">$</span>(<span class="str">'.thing'</span>).<span class="fn">waypoint</span>(); <span class="cm">// error</span></code></pre>
<p>The waypoint callback function takes one parameter, <code>direction</code>. For vertical waypoints direction may be <code>'up'</code> or <code>'down'</code>. For horizontal waypoints, <code>'left'</code> or <code>'right'</code>.</p>
<pre><code><span class="fn">$</span>(<span class="str">'.thing'</span>).<span class="fn">waypoint</span>(<span class="kw">function</span>(direction) {
<span class="fn">alert</span>(direction); <span class="cm">// up, down, left, or right</span>
});</code></pre>
</div>
<div id="doc-options" class="doc-section">
<p>The options object lets you define where in the viewport to trigger the waypoint, whether the waypoint should be on the horizontal axis, and much more.</p>
<pre><code>$.fn.waypoint.defaults = {
<span class="key">context</span>: window,
<span class="key">continuous</span>: <span class="kw">true</span>,
<span class="key">enabled</span>: <span class="kw">true</span>,
<span class="key">horizontal</span>: <span class="kw">false</span>,
<span class="key">offset</span>: 0,
<span class="key">triggerOnce</span>: <span class="kw">false</span>
}</code></pre>
<dl class="options-list">
<dt>context</dt>
<dd class="option-type">string, HTMLElement, or jQuery object</dd>
<dd class="option-default">default: window</dd>
<dd>
<p>The <code>context</code> defines which scrollable element the waypoint belongs to and acts within. The default, <code>window</code>, means the waypoint offset is calculated with relation to the whole viewport. You can set this to another element to use the waypoints within that element. It accepts a selector string, raw HTML element, or jQuery object.</p>
<pre><code><span class="fn">$</span>(<span class="str">'.something-scrollable .thing'</span>).<span class="fn">waypoint</span>({
<span class="key">context</span>: <span class="str">'.something-scrollable'</span>
});</code></pre>
</dd>
<dt>continuous</dt>
<dd class="option-type">boolean</dd>
<dd class="option-default">default: true</dd>
<dd>
<p>If true, and multiple waypoints are triggered in one scroll, this waypoint will trigger even if it is not the last waypoint reached. If false, it will only trigger if it is the last waypoint.</p>
</dd>
<dt>enabled</dt>
<dd class="option-type">boolean</dd>
<dd class="option-default">default: true</dd>
<dd>
<p>If false, this waypoint will be created but will be disabled from triggering. You must call <a href="#docs-enable">enable</a> to turn it back on.</p>
</dd>
<dt>handler</dt>
<dd class="option-type">function</dd>
<dd class="option-default">default: undefined</dd>
<dd>
<p>The waypoint's callback function can be passed in as the value of the <code>handler</code> option instead of as the first parameter to <code>.waypoint</code>. This is generally much nicer for users writing CoffeeScript.</p>
<pre><code><span class="fn">$</span>(<span class="str">'.thing'</span>).<span class="fn">waypoint</span>({
<span class="key">handler</span>: <span class="kw">function</span>(direction) {
<span class="cm">// do stuff</span>
}
});</code></pre>
</dd>
<dt>horizontal</dt>
<dd class="option-type">boolean</dd>
<dd class="option-default">default: false</dd>
<dd>
<p>Default waypoints live on the vertical axis. Their <code>offset</code> is calculated in relation to the <em>top</em> of the viewport and they listen for vertical scroll changes. If <code>horizontal</code> is set to true, <code>offset</code> is calculated in relation to the <em>left</em> of the viewport and listens for horizontal scroll changes.</p>
<pre><code><span class="fn">$</span>(<span class="str">'.thing'</span>).<span class="fn">waypoint</span>({
<span class="key">horizontal</span>: <span class="kw">true</span>,
<span class="key">offset</span>: 50 <span class="cm">// when the left side of this element reaches</span>
<span class="cm">// 50px from the left side of the viewport.</span>
});</code></pre>
</dd>
<dt>offset</dt>
<dd class="option-type">number, string, or function</dd>
<dd class="option-default">default: 0</dd>
<dd>
<p>This option determines how far the top of the element must be from the top of the viewport to trigger the callback function. If <code>offset</code> is a number, it refers to the number of pixels between the viewport top and element top. The default of <code>0</code> means the waypoint triggers when the top of the element hits the top of the viewport. A value of <code>250</code> would trigger when the element is 250px from the top of the viewport.</p>
<pre><code><span class="fn">$</span>(<span class="str">'.thing'</span>).<span class="fn">waypoint</span>({
<span class="key">offset</span>: 250
});</code></pre>
<p>A string value with a percentage refers to a percentage of the height of the viewport. A value of <code>'50%'</code> would trigger the waypoint when the top of the element reaches the dead middle of the screen.</p>
<pre><code><span class="fn">$</span>(<span class="str">'.thing'</span>).<span class="fn">waypoint</span>({
<span class="key">offset</span>: <span class="str">'50%'</span>
});</code></pre>
<p>Pixel and percentage values can also accept negative values, which behave as you may expect, triggering the waypoint when the top of the element goes a distance <em>past</em> the top of the viewport.</p>
<p>The <code>offset</code> may also be defined by a function. This function needs to return a <code>number</code>. The <code>this</code> keyword within the function is the raw HTML element of the waypoint. This example sets the waypoint to trigger when the middle of the element hits the top of the viewport.</p>
<pre><code><span class="fn">$</span>(<span class="str">'.thing'</span>).<span class="fn">waypoint</span>({
<span class="key">offset</span>: <span class="kw">function</span>() {
<span class="kw">return</span> -<span class="fn">$</span>(<span class="kw">this</span>).<span class="fn">height</span>() / 2;
}
});</code></pre>
<p>Vertical waypoints may also use the value <code>'bottom-in-view'</code>. This is a shortcut for a common function that sets the waypoint to trigger when the bottom of the element hits the bottom of the viewport.</p>
<pre><code><span class="fn">$</span>(<span class="str">'.thing'</span>).<span class="fn">waypoint</span>({
<span class="key">offset</span>: <span class="str">'bottom-in-view'</span>
});</code></pre>
</dd>
<dt>triggerOnce</dt>
<dd class="option-type">boolean</dd>
<dd class="option-default">default: false</dd>
<dd>
<p>If true, the waypoint will destroy itself after its first trigger. This is the same as calling <code>.waypoint('destroy')</code> at the end of the callback function.</p>
</dd>
</dl>
</div>
<div id="doc-disable" class="doc-section">
<h2>.waypoint('disable')</h2>
<p>Temporarily disables the waypoint callback function from firing. The waypoint can be re-enabled by calling <a href="#doc-enable">enable</a>.</p>
<pre><code><span class="fn">$</span>(<span class="str">'.thing'</span>).<span class="fn">waypoint</span>(<span class="str">'disable'</span>);</code></pre>
</div>
<div id="doc-enable" class="doc-section">
<h2>.waypoint('enable')</h2>
<p>Re-enables a previously <a href="#doc-disable">disabled</a> waypoint.</p>
<pre><code><span class="fn">$</span>(<span class="str">'.thing'</span>).<span class="fn">waypoint</span>(<span class="str">'enable'</span>);</code></pre>
</div>
<div id="doc-destroy" class="doc-section">
<h2>.waypoint('destroy')</h2>
<p>Destroys all waypoints associated with these elements.</p>
<pre><code><span class="fn">$</span>(<span class="str">'.thing'</span>).<span class="fn">waypoint</span>(<span class="str">'destroy'</span>);</code></pre>
</div>
<div id="doc-prev" class="doc-section">
<h2>.waypoint('prev', [axis], [context])</h2>
<ul class="params">
<li>
<h3>axis</h3>
<dl>
<dt>type</dt>
<dd>string, optional</dd>
<dt>allowed</dt>
<dd>'vertical', 'horizontal'</dd>
<dt>default</dt>
<dd>'vertical'</dd>
</dl>
</li>
<li>
<h3>context</h3>
<dl>
<dt>type</dt>
<dd>string, HTMLElement, or jQuery object, optional</dd>
<dt>default</dt>
<dd>window</dd>
</dl>
</li>
</ul>
<p>Returns a jQuery object containing the previous waypoint, as measured by the waypoints' trigger locations.</p>
<pre><code><span class="fn">$</span>(<span class="str">'#thing'</span>).<span class="fn">waypoint</span>(...);
<span class="fn">$</span>(<span class="str">'#thing-farther-down'</span>).<span class="fn">waypoint</span>(...);
<span class="fn">$</span>(<span class="str">'#thing-farther-down'</span>).<span class="fn">waypoint</span>(<span class="str">'prev'</span>);
<span class="cm">// returns #thing jQuery object</span></code></pre>
</div>
<div id="doc-next" class="doc-section">
<h2>.waypoint('next', [axis], [context])</h2>
<ul class="params">
<li>
<h3>axis</h3>
<dl>
<dt>type</dt>
<dd>string, optional</dd>
<dt>allowed</dt>
<dd>'vertical', 'horizontal'</dd>
<dt>default</dt>
<dd>'vertical'</dd>
</dl>
</li>
<li>
<h3>context</h3>
<dl>
<dt>type</dt>
<dd>string, HTMLElement, or jQuery object, optional</dd>
<dt>default</dt>
<dd>window</dd>
</dl>
</li>
</ul>
<p>Returns a jQuery object containing the next waypoint, as measured by the waypoints' trigger locations.</p>
<pre><code><span class="fn">$</span>(<span class="str">'#thing'</span>).<span class="fn">waypoint</span>(...);
<span class="fn">$</span>(<span class="str">'#thing-farther-down'</span>).<span class="fn">waypoint</span>(...);
<span class="fn">$</span>(<span class="str">'#thing'</span>).<span class="fn">waypoint</span>(<span class="str">'next'</span>);
<span class="cm">// returns #thing-farther-down jQuery object</span></code></pre>
</div>
<div id="doc-waypoints" class="doc-section">
<h2>$.waypoints([contextSelector])</h2>
<ul class="params">
<li>
<h3>contextSelector</h3>
<dl>
<dt>type</dt>
<dd>string, optional</dd>
<dt>default</dt>
<dd>window</dd>
</dl>
</li>
</ul>
<p>Returns an object with two keys, <code>vertical</code> and <code>horizontal</code>. Each of these key values is an HTMLElement array containing all waypoint elements on that axis. If <code>contextSelector</code> is provided, it only returns elements with a context matching that context selector. If no parameter is supplied, all waypoint elements are returned.</p>
<pre><code><span class="fn">$</span>(<span class="str">'.thing'</span>).<span class="fn">waypoint</span>(...);
$.<span class="fn">waypoints</span>();
<span class="cm">// returns {</span>
<span class="cm">// vertical: [(all .thing elements)]</span>
<span class="cm">// horizontal: []</span>
<span class="cm">// }</span></code></pre>
</div>
<div id="doc-refresh" class="doc-section">
<h2>$.waypoints('refresh')</h2>
<p>This will force a recalculation of each waypoint’s trigger point based on its offset option. This is called automatically whenever the window is resized or new waypoints are added. If your project is changing the DOM or page layout without doing one of these things, you may want to manually call it.</p>
<pre><code>$.<span class="fn">waypoints</span>(<span class="str">'refresh'</span>);</code></pre>
</div>
<div id="doc-viewport-height" class="doc-section">
<h2>$.waypoints('viewportHeight')</h2>
<p>Return the height of the viewport, adjusting for inconsistencies that come with calling <code>$(window).height()</code> in iOS. When writing offset functions that use the window's height, using this is recommended.</p>
<pre><code>$.<span class="fn">waypoints</span>(<span class="str">'viewportHeight'</span>);</code></pre>
</div>
<div id="doc-above" class="doc-section">
<h2>$.waypoints('above', [contextSelector])</h2>
<ul class="params">
<li>
<h3>contextSelector</h3>
<dl>
<dt>type</dt>
<dd>string, optional</dd>
<dt>default</dt>
<dd>window</dd>
</dl>
</li>
</ul>
<p>Returns an array of HTMLElements. This array contains all waypoint elements with trigger points that lie above the current scroll position of the <code>contextSelector</code> element.</p>
<pre><code><span class="fn">$</span>(<span class="str">'.things'</span>).<span class="fn">waypoint</span>(...);
$.<span class="fn">waypoints</span>(<span class="str">'above'</span>);
<span class="cm">// returns all "things" above current scroll position</span></code></pre>
</div>
<div id="doc-below" class="doc-section">
<h2>$.waypoints('below', [contextSelector])</h2>
<ul class="params">
<li>
<h3>contextSelector</h3>
<dl>
<dt>type</dt>
<dd>string, optional</dd>
<dt>default</dt>
<dd>window</dd>
</dl>
</li>
</ul>
<p>Returns an array of HTMLElements. This array contains all waypoint elements with trigger points that lie below the current scroll position of the <code>contextSelector</code> element.</p>
<pre><code><span class="fn">$</span>(<span class="str">'.things'</span>).<span class="fn">waypoint</span>(...);
$.<span class="fn">waypoints</span>(<span class="str">'below'</span>);
<span class="cm">// returns all "things" below current scroll position</span></code></pre>
</div>
<div id="doc-left" class="doc-section">
<h2>$.waypoints('left', [contextSelector])</h2>
<ul class="params">
<li>
<h3>contextSelector</h3>
<dl>
<dt>type</dt>
<dd>string, optional</dd>
<dt>default</dt>
<dd>window</dd>
</dl>
</li>
</ul>
<p>Returns an array of HTMLElements. This array contains all waypoint elements with trigger points that lie to the left of the current scroll position of the <code>contextSelector</code> element.</p>
<pre><code><span class="fn">$</span>(<span class="str">'.things'</span>).<span class="fn">waypoint</span>(...);
$.<span class="fn">waypoints</span>(<span class="str">'left'</span>);
<span class="cm">// returns all "things" left of current scroll position</span></code></pre>
</div>
<div id="doc-right" class="doc-section">
<h2>$.waypoints('right', [contextSelector])</h2>
<ul class="params">
<li>
<h3>contextSelector</h3>
<dl>
<dt>type</dt>
<dd>string, optional</dd>
<dt>default</dt>
<dd>window</dd>
</dl>
</li>
</ul>
<p>Returns an array of HTMLElements. This array contains all waypoint elements with trigger points that lie to the right of the current scroll position of the <code>contextSelector</code> element.</p>
<pre><code><span class="fn">$</span>(<span class="str">'.things'</span>).<span class="fn">waypoint</span>(...);
$.<span class="fn">waypoints</span>(<span class="str">'right'</span>);
<span class="cm">// returns all "things" right of current scroll position</span></code></pre>
</div>
<div id="doc-disable-all" class="doc-section">
<h2>$.waypoints('disable')</h2>
<p>Disables all waypoints.</p>
</div>
<div id="doc-enable-all" class="doc-section">
<h2>$.waypoints('enable')</h2>
<p>Re-enables all waypoints.</p>
</div>
<div id="doc-destroy-all" class="doc-section">
<h2>$.waypoints('destroy')</h2>
<p>Destroys all waypoints.</p>
</div>
<div id="doc-extend" class="doc-section">
<h2>$.waypoints('extendFn', name, method)</h2>
<ul class="params">
<li>
<h3>name</h3>
<dl>
<dt>type</dt>
<dd>string, required</dd>
</dl>
</li>
<li>
<h3>method</h3>
<dl>
<dt>type</dt>
<dd>function, required</dd>
</dl>
</li>
</ul>
<p>Adds <code>method</code> to the <a href="#doc-waypoint">.waypoint</a> namespace under the <code>name</code> key. <a href="#shortcuts-examples">Shortcuts</a> use this to add their methods to jQuery Waypoints.</p>
<pre><code>$.<span class="fn">waypoints</span>(<span class="str">'extendFn'</span>, <span class="str">'alert'</span>, <span class="kw">function</span>(msg) {
<span class="fn">alert</span>(msg + <span class="kw">this</span>.id);
});
<span class="fn">$</span>(<span class="str">'#thing'</span>).<span class="fn">waypoint</span>(<span class="str">'alert'</span>, <span class="str">'Foo: '</span>);
<span class="cm">// Alerts "Foo: thing"</span></code></pre>
</div>
</div>
</div>
<div class="notifications-wrapper">
<div class="notifications"></div>
</div>
<p class="footer">A project of <a href="http://imakewebthings.com">I Make Web Things</a></p>
<script src="jquery.js"></script>
<script src="waypoints.js"></script>
<script src="index.js"></script>
</body>
</html>