-
Notifications
You must be signed in to change notification settings - Fork 878
/
demo.html
594 lines (520 loc) · 25.1 KB
/
demo.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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Vanilla Javascript Parallax Library - Rellax.js</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<link href='https://fonts.googleapis.com/css?family=Source+Sans+Pro:600,700,900' rel='stylesheet' type='text/css'>
<!-- Booooooootstrap -->
<link rel="stylesheet" href="css/bootstrap.min.css">
<!-- Styles -->
<link rel="stylesheet" type="text/css" href="css/main.css">
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<script>window.html5 || document.write('<script src="js/vendor/html5shiv.js"><\/script>')</script>
<![endif]-->
</head>
<body>
<div class="grid">
<div class="container">
<div class="row">
<div class="col-md-offset-1 col-md-2">
<div class="grid-line"></div>
</div>
<div class="col-md-2">
<div class="grid-line"></div>
</div>
<div class="col-md-2">
<div class="grid-line"></div>
</div>
<div class="col-md-2">
<div class="grid-line"></div>
</div>
<div class="col-md-2">
<div class="grid-line" style="margin-right:-30px;border-right:1px solid #ccc"></div>
</div>
</div>
</div>
</div>
<div class="fixed-top rellax" data-rellax-speed="-2" data-rellax-xs-speed="-5" data-rellax-mobile-speed="3"
data-rellax-tablet-speed="-8" style="transform: rotate(45deg);">
</div>
<main class="main">
<header>
<div class="container">
<div class="row">
<div class="col-md-offset-1 col-md-11">
<a href="http://dixonandmoe.com/">
<h2>BY DIXON & MOE <span>➔</span></h2>
</a>
<div class="white-block"></div>
</div>
</div>
<div class="title">
<div class="row">
<div class="col-md-offset-1 col-md-6">
<h1>RELLAX<span>JS</span></h1>
</div>
<div class="col-md-4 text-right">
<a href="https://github.com/dixonandmoe/rellax">GITHUB</a>
</div>
</div>
</div>
<div class="subtitle">
<div class="row">
<div class="col-md-offset-1 col-md-2">
<h3>Light (871b gz)</h3>
</div>
<div class="col-md-2">
<h3>Vanilla Javascript</h3>
</div>
<div class="col-md-2">
<h3>Parallax Library</h3>
</div>
</div>
</div>
</div>
</header>
<section class="section san-francisco">
<div class="absolute">
<div class="container">
<div class="row">
<div class="col-md-offset-1 col-md-11">
<h2 class="rellax" data-rellax-speed="-3" data-rellax-xs-speed="-5" data-rellax-mobile-speed="4"
data-rellax-tablet-speed="-3">
San Francisco<br>California
</h2>
</div>
</div>
</div>
</div>
<div class="absolute above">
<div class="container">
<div class="row">
<div class="col-md-offset-1 col-md-2">
<div class="lg-green rellax" data-rellax-speed="2" data-rellax-xs-speed="1" data-rellax-mobile-speed="2"
data-rellax-tablet-speed="2" style="transform: rotate(45deg);">
</div>
<div class="sm-green rellax" data-rellax-speed="5" data-rellax-xs-speed="3" data-rellax-mobile-speed="4"
data-rellax-tablet-speed="5" style="transform: rotate(45deg);">
</div>
</div>
<div class="col-md-offset-2 col-md-1">
<div class="sm-purple rellax" data-rellax-speed="2" data-rellax-xs-speed="1" data-rellax-mobile-speed="2"
data-rellax-tablet-speed="2" style="transform: rotate(45deg);">
</div>
</div>
<div class="col-md-offset-3 col-md-1">
<div class="xs-green rellax" data-rellax-speed="5" data-rellax-xs-speed="3" data-rellax-mobile-speed="4"
data-rellax-tablet-speed="5" style="transform: rotate(45deg);">
</div>
<div class="md-green rellax" data-rellax-speed="1" data-rellax-xs-speed="1" data-rellax-mobile-speed="2"
data-rellax-tablet-speed="2" style="transform: rotate(45deg);">
</div>
</div>
<div class="col-md-1">
<div class="lg-purple rellax" data-rellax-speed="3" data-rellax-xs-speed="2" data-rellax-mobile-speed="2"
data-rellax-tablet-speed="3" style="transform: rotate(45deg);">
</div>
</div>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-md-offset-1 col-md-5">
<div class="date">
Incorporated—<br>
1850<br><br>
37°47′N 122°25′W
</div>
</div>
<div class="col-md-offset-1 col-md-4">
<div class="temp">
68°
</div>
</div>
</div>
</div>
</section>
<section class="documentation">
<div class="container">
<section class="row">
<div class="col-md-4 sticky">
<div class="options" id="optnCard">
<p class="options-text disabled">Options</p>
<a href="#GettingStarted" class="option options-title active">Getting Started!</a>
<a class="option options-title" href="#Speed">Speed</a>
<a class="option options-title" href="#Centering">Centering</a>
<a class="option options-title" href="#ZIndex">Z-Index</a>
<a class="option options-title" href="#HorParlx">Horizontal Scrolling</a>
<!-- <span>➔</span> -->
<a class="option options-title" href="#CustomWrapper">Custom Wrapper</a>
<a class="option options-title" href="#TargetNode">Target Node</a>
<p class="options-text options-text--margin">Methods</p>
<a class="option options-title" href="#Refresh">Refresh</a>
<a class="option options-title" href="#Destroy">Destroy</a>
</div>
</div>
<div class="col-md-8">
<!-- Getting Started -->
<section class="section" id="GettingStarted">
<div style="margin-top: 6rem">
<div>
<!-- sect1 -->
<h2 class="heading">Getting Started!</h2>
<div class="text-editor">
<code>
<span class="orange">npm install rellax --save</span>
</code>
</div>
<p style="font-weight: lighter;">
or if you're old school like us, download and insert
<kbd><script src="https://cdn.jsdelivr.net/gh/dixonandmoe/rellax@master/rellax.min.js"></script></kbd> file in your project folder.
</p>
</div>
<div>
<!-- sect2 -->
<h3 class="heading">JavaScript (`accepts any class name`)</h3>
<div class="text-editor">
<code>
<span class="purple">var</span> rellax = <span class="green">new</span> <span class="white">Rellax</span>('.rellax');
</code>
</div>
</div>
<div>
<!-- sect3 -->
<h3 class="heading">Basic Markup (Default Speed: -2)</h3>
<div class="text-editor">
<code>
<div <span class="purple">class</span>="<span class="green">rellax</span>"><br>
<span class="white"> I’m slow and smooth</span><br>
</div>
</code>
</div>
</div>
<div>
<!-- sect4 -->
<h3 class="heading">Optional Speed (-10 to +10)</h3>
<div class="text-editor">
<code>
<div <span class="purple">class</span>="<span class="green">rellax</span>" <span class="purple">data-rellax-speed</span>="<span class="green">-3</span>"><br>
<span class="white"> I’m slow and smooth</span><br>
</div>
<br />
<br>
<div <span class="purple">class</span>="<span class="green">rellax</span>" <span class="purple">data-rellax-speed</span>="<span class="green">7</span>"><br>
<span class="white"> I’m super fast!!</span><br>
</div>
<br />
<br>
<div <span class="purple">class</span>="<span class="green">rellax</span>" <span class="purple">data-rellax-speed</span>="<span class="green">-5</span>"><br>
<span class="white"> I’m extra slow and smooth</span><br>
</div>
<br />
</code>
</div>
</div>
</div>
</section>
<!-- Speed -->
<section class="section" id="Speed">
<div style="margin-top: 6rem">
<!-- sect1 -->
<h2 class="heading">Speed</h2>
<p style="font-weight: lighter;">
Use the <kbd>data-rellax-speed</kbd> attribute to set the speed of a
<kbd>.rellax</kbd> element to something other than the default value
(which is <kbd>-2</kbd>). A negative value will make it move slower
than regular scrolling, and a positive value will make it move faster.
We recommend keeping the speed between <kbd>-10 and +10</kbd>.
</p>
<div>
<!-- sect2 -->
<h3 class="heading">Responsive Speed</h3 style="margin-top: 4rem">
<p style="font-weight: lighter;">
Use responsive speed attributes for breakpoint levels that require a
different speed. Defaults to the <kbd>data-rellax-speed</kbd> setting
in unspecified breakpoints.
</p>
<div class="text-editor">
<code>
<div
<br> <span class="purple">class</span>="<span class="green">rellax</span>"
<br> <span class="purple">data-rellax-speed</span>="<span class="green">7</span>"
<br> <span class="purple">data-rellax-xs-speed</span>="<span class="green">-5</span>"
<br> <span class="purple">data-rellax-mobile-speed</span>="<span class="green">3</span>"
<br> <span class="purple">data-rellax-tablet-speed</span>="<span class="green">-8</span>"
<br> <span class="purple">data-rellax-desktop-speed</span>="<span class="green">1</span>"><br>
<span class="white"> I parallax at all different speeds depending on your screen width.</span><br>
</div>
</code>
</div>
<p style="font-weight: lighter;">
Pass an array of breakpoints. Each breakpoint value represents the
resolution for mobile, tablet, desktop respectively. Checkout the
responsiveness of the demo.
</p>
<div class="text-editor">
<code>
<script>
<br> <span class="comment">//default JS Setting</span>
<br> <span class="purple">var</span> rellax = <span class="green">new</span> <span class="white">Rellax</span>('.rellax',
<span class="white">
{<br>
<span class="green">breakpoints:</span>[<span class="orange">576, 768, 1201</span>]
<br> }</span>);
<br />
</script>
</code>
</div>
</div>
</div>
</section>
<!-- Centering -->
<section class="section" id="Centering">
<div style="margin-top: 6rem">
<!-- sect1 -->
<h2 class="heading">Centering</h2>
<p style="font-weight: lighter;">
After some fantastic work from <kbd><a style="color: orange;"
href="https://github.com/p-realinho">@p-realinho</a></kbd>, we
just released the ability to center parallax elements in your viewport!
We'll be building a nice demo website, but for now check out the tests
folder for several examples of how it works via our tests folder on
<a href="https://github.com/dixonandmoe/rellax">GitHub</a>.
</p>
<br>
<p style="font-weight: lighter;">
There's two ways to implement centering, either on specific elements or as a global option.
</p>
<div class="text-editor">
<code>
<div <span class="purple">class</span>="<span class="green">rellax</span>" <span class="purple">data-rellax-percentage</span>="<span class="green">0.5</span>"><br>
<span class="white"> I’m that default chill speed of "-2" and "centered"</span><br>
</div>
<br />
<br>
<div <span class="purple">class</span>="<span class="green">rellax</span>" <span class="purple">data-rellax-speed</span>="<span class="green">7</span>"
<br> <span class="purple">data-rellax-percentage</span>="<span class="green">0.5</span>"><br>
<span class="white"> I’m super fast!! And super centered!!</span><br>
</div>
<br />
<br>
<div <span class="purple">class</span>="<span class="green">rellax</span>" <span class="purple">data-rellax-speed</span>="<span class="green">-4</span>"
<br> <span class="purple">data-rellax-percentage</span>="<span class="green">0.5</span>"><br>
<span class="white"> I’m extra slow and smooth, and hella centered.</span><br>
</div>
<br />
</code>
</div>
<div>
<!-- sect2 -->
<div style="margin-top: 5rem;">
<div class="text-editor">
<code>
<script>
<br> <span class="comment">//default JS Setting</span>
<br> <span class="purple">var</span> rellax = <span class="green">new</span> <span class="white">Rellax</span>('.rellax',
<span class="white">
{<br>
<span class="green">center:</span><span class="orange">true</span>
<br> }</span>);
<br />
</script>
</code>
</div>
</div>
</div>
</div>
</section>
<!-- Z-index -->
<section class="section" id="ZIndex">
<div style="margin-top: 6rem">
<!-- sect1 -->
<h2 class="heading">Z-Index</h2>
<p style="font-weight: lighter;">
If you want to sort your elements properly in the Z space,
you can use the <br><kbd>data-rellax-zindex</kbd> property.
</p>
<br>
<div class="text-editor">
<code>
<div <span class="purple">class</span>="<span class="green">rellax</span>"><br>
<span class="white"> I’m that default chill speed of "-2" and default z-index of 0</span><br>
</div>
<br />
<br>
<div <span class="purple">class</span>="<span class="green">rellax</span>" <span class="purple">data-rellax-speed</span>="<span class="green">7</span>"
<br> <span class="purple">data-rellax-zindex</span>="<span class="green">5</span>"><br>
<span class="white"> I’m super fast!! And on top of the previous element, I'm z-index 5!!</span><br>
</div>
<br />
</code>
</div>
</div>
</section>
<!-- Horizontal Parallax -->
<section class="section" id="HorParlx">
<div style="margin-top: 6rem">
<!-- sect1 -->
<h2 class="heading">Horizontal Parallax</h2>
<p style="font-weight: lighter;">
Horizontal parallax is disabled by default. You can enable it by passing
<br><kbd><span class="orange">horizontal: true</span></kbd> in the settings
block. This feature is intended for panoramic style websites, where users
scroll horizontally instead of vertically. Note that this can work together
at the same time with the default vertical parallax. If you do not want this,
pass <kbd><span class="orange">vertical: false</span></kbd>.
</p>
<br>
<div class="text-editor">
<code>
<script>
<br> <span class="comment">//Enable Horizontal Parallax Scrolling</span>
<br> <span class="purple">var</span> rellax = <span class="green">new</span> <span class="white">Rellax</span>('.rellax',
<span class="white">
{<br>
<span class="green">horizontal:</span><span class="orange">true</span>
</br ><br> <span class="comment">//Disable vertical Parallax Scrolling</span>
<span class="green">vertical:</span><span class="orange">false</span>
<br> }</span>);
<br />
</script>
</code>
</div>
</div>
</section>
<!-- Custom Wrapper -->
<section class="section" id="CustomWrapper">
<div style="margin-top: 6rem">
<!-- sect1 -->
<h2 class="heading">Custom Wrapper</h2>
<p style="font-weight: lighter;">
By default, the position of parallax elements is determined via the scroll
position of the body. Passing in the <kbd><span class="orange">wrapper</span></kbd>
property in the settings block will tell Rellax to watch that element instead.
</p>
<br>
<div class="text-editor">
<code>
<script>
<br> <span class="comment">//Set wrapper to .custom-element instead of the body</span>
<br> <span class="purple">var</span> rellax = <span class="green">new</span> <span class="white">Rellax</span>('.rellax',
<span class="white">
{<br>
<span class="green">wrapper:</span><span class="orange">'.custom-element'</span>
<br> }</span>);
<br />
</script>
</code>
</div>
</div>
</section>
<!-- Target Node -->
<section class="section" id="TargetNode">
<div style="margin-top: 6rem">
<!-- sect1 -->
<h2 class="heading">Target Node</h2>
<p style="font-weight: lighter;">
Instead of using a className you can use a node, handy when using
React and you want to use <kbd><span class="orange">refs</span></kbd>
instead of <kbd><span class="orange">className</span></kbd>
</p>
<br>
<div class="text-editor">
<code>
<div <span class="purple">ref</span> = {<span class="purple">ref => </span>{ this<span class="green">.rellaxRef </span> = <span class="purple">ref</span>}}><br>
<span class="white"> I’m that default chill speed of "-2"</span><br>
</div>
</code>
<br />
</div>
<div style="margin-top: 5rem;">
<div class="text-editor">
<code>
<script>
<br> <span class="purple">var</span> rellax = <span class="green">new</span> <span class="white">Rellax</span>(this<span class="orange">.rellaxRef</span>);
<br>
</script>
</code>
</div>
</div>
</div>
</section>
<!-- Refresh -->
<section class="section" id="Refresh">
<div style="margin-top: 6rem">
<!-- sect1 -->
<h2 class="heading">Refresh</h2>
<div class="text-editor">
<code>
<script>
<br> <span class="comment">// Start Rellax</span>
<br> <span class="purple">var</span> rellax = <span class="green">new</span> <span class="white">Rellax</span>('.rellax');
<br />
<br> <span class="comment">// Destroy and create again parallax with previous settings</span>
<br> rellax<span class="orange">.refresh();</span>
<br>
</script>
</code>
</div>
</div>
</section>
<!-- Destroy -->
<section class="section" id="Destroy">
<div style="margin-top: 6rem">
<!-- sect1 -->
<h2 class="heading">Destroy</h2>
<div class="text-editor">
<code>
<script>
<br> <span class="comment">// Start Rellax</span>
<br> <span class="purple">var</span> rellax = <span class="green">new</span> <span class="white">Rellax</span>('.rellax');
<br />
<br> <span class="comment">// End Rellax and reset parallax elements to their original positions</span>
<br> rellax<span class="orange">.refresh();</span>
<br>
</script>
</code>
</div>
</div>
</section>
</div>
</section>
</div>
</section>
<section class="share">
<div class="container">
<div class="row">
<div class="col-md-offset-1 col-md-3">
<a class="dam" href="http://dixonandmoe.com/">Dixon & Moe</a>
</div>
<div class="col-md-offset-3 col-md-2">
<a href="https://www.facebook.com/sharer/sharer.php?u=http://dixonandmoe.com/rellax/">Share
<span>➔</span></a>
</div>
<div class="col-md-offset-0 col-md-2">
<a href="https://twitter.com/share?url=http://dixonandmoe.com/rellax/">Tweet <span>➔</span></a>
</div>
</div>
</div>
</section>
</main>
<!-- javascript -->
<script type="text/javascript" src="rellax.js"></script>
<script type="text/javascript" src="option.js"></script>
<script>
var rellax = new Rellax('.rellax', {
// center: true
callback: function (position) {
// callback every position change
console.log(position);
},
breakpoints: [576, 768, 1024]
});
</script>
</body>
</html>