-
Notifications
You must be signed in to change notification settings - Fork 243
/
index.html
922 lines (771 loc) · 36.8 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
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
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>lory</title>
<meta name="description" content="Touch enabled minimalistic slider written in vanilla JavaScript">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" type="image/ico" href="./static/favicon.ico" />
<link rel="stylesheet" type="text/css" href="./static/app.css" />
<link rel="stylesheet" type="text/css" href="./static/vendor/railscasts.css" />
<link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,700' rel='stylesheet' type='text/css'>
</head>
<body>
<header>
<div class="ribbon">
<a href="https://github.com/meandmax/lory">Fork me on GitHub</a>
</div>
<img class="logo" src="./static/lory.png" />
</header>
<p class="description">Touch enabled minimalistic slider written in vanilla JavaScript</p>
<p class="description">Hardware accelerated transitions</p>
<p class="description">Usable as a jQuery plugin</p>
<p class="description">Options for custom easing effects</p>
<p class="description">infinite looping ~ carousel</p>
<p class="description">No compromises for fallbacks</p>
<p class="description">Written in ecmascript 6</p>
<p class="description">Using webpack, babel & eslint for development</p>
<a class="dist" href="./dist/lory.min.js" download>Download Here</a>
<p class="description">or via cdn from <a href="https://cdnjs.com/libraries/lory.js/" target="_blank">cdnjs</a></p>
<section class="prerequisited">
<div class="examplecode">
<h2>Prerequisited Html structure<br><small><em>Class names can be changed through options</em></small></h2>
<pre><code class="html">
<div class="slider js_slider">
<div class="frame js_frame">
<ul class="slides js_slides">
<li class="js_slide">1</li>
<li class="js_slide">2</li>
<li class="js_slide">3</li>
<li class="js_slide">4</li>
<li class="js_slide">5</li>
<li class="js_slide">6</li>
</ul>
</div>
<span class="js_prev prev">
<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="0 0 501.5 501.5"><g><path fill="#2E435A" d="M302.67 90.877l55.77 55.508L254.575 250.75 358.44 355.116l-55.77 55.506L143.56 250.75z"/></g></svg>
</span>
<span class="js_next next">
<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="0 0 501.5 501.5"><g><path fill="#2E435A" d="M199.33 410.622l-55.77-55.508L247.425 250.75 143.56 146.384l55.77-55.507L358.44 250.75z"/></g></svg>
</span>
</div>
</code></pre></div>
<div class="examplecode">
<h2>Prerequisited CSS styles</h2>
<pre><code class="css">
/**
* (optional) define here the style definitions which should be applied on the slider container
* e.g. width including further controls like arrows etc.
*/
.slider {}
.frame {
/**
* (optional) wrapper width, specifies width of the slider frame.
*/
width: 880px;
position: relative;
font-size: 0;
line-height: 0;
overflow: hidden;
white-space: nowrap;
}
.slides {
display: inline-block;
}
li {
position: relative;
display: inline-block;
/**
* (optional) if the content inside the slide element has a defined size.
*/
width: 880px;
}
.prev, .next {
position: absolute;
top: 50%;
margin-top: -25px;
display: block;
cursor: pointer;
}
.next {
right: 0;
}
.prev {
left: 0;
}
.next svg, .prev svg {
width: 25px;
}
</code></pre></div>
</section>
<section class="examples">
<h2>Single element - Fixed width [infinite]</h2>
<div class="slider js_simple simple">
<div class="frame js_frame">
<ul class="slides js_slides">
<li class="js_slide">1</li>
<li class="js_slide">2</li>
<li class="js_slide">3</li>
<li class="js_slide">4</li>
<li class="js_slide">5</li>
<li class="js_slide">6</li>
</ul>
</div>
<span class="js_prev prev">
<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="0 0 501.5 501.5"><g><path fill="#2E435A" d="M302.67 90.877l55.77 55.508L254.575 250.75 358.44 355.116l-55.77 55.506L143.56 250.75z"/></g></svg>
</span>
<span class="js_next next">
<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="0 0 501.5 501.5"><g><path fill="#2E435A" d="M199.33 410.622l-55.77-55.508L247.425 250.75 143.56 146.384l55.77-55.507L358.44 250.75z"/></g></svg>
</span>
</div>
<div class="examplecode"><pre><code class="javascript">
document.addEventListener('DOMContentLoaded', function () {
var simple = document.querySelector('.js_simple');
lory(simple, {
infinite: 1
});
});
</code></pre></div>
<h2>Single element - dot navigation</h2>
<div class="slider js_simple_dots simple">
<div class="frame js_frame">
<ul class="slides js_slides">
<li class="js_slide">1</li>
<li class="js_slide">2</li>
<li class="js_slide">3</li>
<li class="js_slide">4</li>
<li class="js_slide">5</li>
<li class="js_slide">6</li>
</ul>
</div>
<span class="js_prev prev">
<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="0 0 501.5 501.5"><g><path fill="#2E435A" d="M302.67 90.877l55.77 55.508L254.575 250.75 358.44 355.116l-55.77 55.506L143.56 250.75z"/></g></svg>
</span>
<span class="js_next next">
<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="0 0 501.5 501.5"><g><path fill="#2E435A" d="M199.33 410.622l-55.77-55.508L247.425 250.75 143.56 146.384l55.77-55.507L358.44 250.75z"/></g></svg>
</span>
<ul class="js_dots dots"></ul>
</div>
<div class="examplecode"><pre><code class="javascript">
document.addEventListener('DOMContentLoaded', function () {
var simple_dots = document.querySelector('.js_simple_dots');
var dot_count = simple_dots.querySelectorAll('.js_slide').length;
var dot_container = simple_dots.querySelector('.js_dots');
var dot_list_item = document.createElement('li');
function handleDotEvent(e) {
if (e.type === 'before.lory.init') {
for (var i = 0, len = dot_count; i < len; i++) {
var clone = dot_list_item.cloneNode();
dot_container.appendChild(clone);
}
dot_container.childNodes[0].classList.add('active');
}
if (e.type === 'after.lory.init') {
for (var i = 0, len = dot_count; i < len; i++) {
dot_container.childNodes[i].addEventListener('click', function(e) {
dot_navigation_slider.slideTo(Array.prototype.indexOf.call(dot_container.childNodes, e.target));
});
}
}
if (e.type === 'after.lory.slide') {
for (var i = 0, len = dot_container.childNodes.length; i < len; i++) {
dot_container.childNodes[i].classList.remove('active');
}
dot_container.childNodes[e.detail.currentSlide - 1].classList.add('active');
}
if (e.type === 'on.lory.resize') {
for (var i = 0, len = dot_container.childNodes.length; i < len; i++) {
dot_container.childNodes[i].classList.remove('active');
}
dot_container.childNodes[0].classList.add('active');
}
}
simple_dots.addEventListener('before.lory.init', handleDotEvent);
simple_dots.addEventListener('after.lory.init', handleDotEvent);
simple_dots.addEventListener('after.lory.slide', handleDotEvent);
simple_dots.addEventListener('on.lory.resize', handleDotEvent);
var dot_navigation_slider = lory(simple_dots, {
infinite: 1,
enableMouseEvents: true
});
});
</code></pre></div>
<h2>Single element - Percentage width [infinite]</h2>
<div class="slider js_percentage percentage">
<div class="frame js_frame">
<ul class="slides js_slides">
<li class="js_slide">1</li>
<li class="js_slide">2</li>
<li class="js_slide">3</li>
<li class="js_slide">4</li>
<li class="js_slide">5</li>
<li class="js_slide">6</li>
</ul>
</div>
<span class="js_prev prev">
<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="0 0 501.5 501.5"><g><path fill="#2E435A" d="M302.67 90.877l55.77 55.508L254.575 250.75 358.44 355.116l-55.77 55.506L143.56 250.75z"/></g></svg>
</span>
<span class="js_next next">
<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="0 0 501.5 501.5"><g><path fill="#2E435A" d="M199.33 410.622l-55.77-55.508L247.425 250.75 143.56 146.384l55.77-55.507L358.44 250.75z"/></g></svg>
</span>
</div>
<div class="examplecode"><pre><code class="javascript">
document.addEventListener('DOMContentLoaded', function () {
var percentage = document.querySelector('.js_percentage');
lory(percentage, {
infinite: 1
});
});
</code></pre></div>
<h2>Single element - Fixed width [rewind]</h2>
<div class="slider js_rewind rewind">
<div class="frame js_frame">
<ul class="slides js_slides">
<li class="js_slide">1</li>
<li class="js_slide">2</li>
<li class="js_slide">3</li>
<li class="js_slide">4</li>
<li class="js_slide">5</li>
<li class="js_slide">6</li>
</ul>
</div>
<span class="js_prev prev">
<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="0 0 501.5 501.5"><g><path fill="#2E435A" d="M302.67 90.877l55.77 55.508L254.575 250.75 358.44 355.116l-55.77 55.506L143.56 250.75z"/></g></svg>
</span>
<span class="js_next next">
<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="0 0 501.5 501.5"><g><path fill="#2E435A" d="M199.33 410.622l-55.77-55.508L247.425 250.75 143.56 146.384l55.77-55.507L358.44 250.75z"/></g></svg>
</span>
</div>
<div class="examplecode"><pre><code class="javascript">
document.addEventListener('DOMContentLoaded', function () {
var rewind = document.querySelector('.js_rewind');
lory(rewind, {
rewind: true
});
});
</code></pre></div>
<h2>Single element - Percentage width [rewind]</h2>
<div class="slider js_rewind_percentage percentage">
<div class="frame js_frame">
<ul class="slides js_slides">
<li class="js_slide">1</li>
<li class="js_slide">2</li>
<li class="js_slide">3</li>
<li class="js_slide">4</li>
<li class="js_slide">5</li>
<li class="js_slide">6</li>
</ul>
</div>
<span class="js_prev prev">
<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="0 0 501.5 501.5"><g><path fill="#2E435A" d="M302.67 90.877l55.77 55.508L254.575 250.75 358.44 355.116l-55.77 55.506L143.56 250.75z"/></g></svg>
</span>
<span class="js_next next">
<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="0 0 501.5 501.5"><g><path fill="#2E435A" d="M199.33 410.622l-55.77-55.508L247.425 250.75 143.56 146.384l55.77-55.507L358.44 250.75z"/></g></svg>
</span>
</div>
<div class="examplecode"><pre><code class="javascript">
document.addEventListener('DOMContentLoaded', function () {
var rewind_percentage = document.querySelector('.js_rewind_percentage');
lory(rewind_percentage, {
rewind: true
});
});
</code></pre></div>
<h2>Variable width</h2>
<div class="slider js_variablewidth variablewidth">
<div class="frame js_frame">
<ul class="slides js_slides">
<li class="js_slide" style="width: 220px;">220</li>
<li class="js_slide" style="width: 190px;">190</li>
<li class="js_slide" style="width: 150px;">150</li>
<li class="js_slide" style="width: 130px;">130</li>
<li class="js_slide" style="width: 250px;">250</li>
<li class="js_slide" style="width: 180px;">180</li>
<li class="js_slide" style="width: 200px;">200</li>
<li class="js_slide" style="width: 140px;">140</li>
<li class="js_slide" style="width: 120px;">120</li>
<li class="js_slide" style="width: 240px;">240</li>
</ul>
</div>
<span class="js_prev prev">
<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="0 0 501.5 501.5"><g><path fill="#2E435A" d="M302.67 90.877l55.77 55.508L254.575 250.75 358.44 355.116l-55.77 55.506L143.56 250.75z"/></g></svg>
</span>
<span class="js_next next">
<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="0 0 501.5 501.5"><g><path fill="#2E435A" d="M199.33 410.622l-55.77-55.508L247.425 250.75 143.56 146.384l55.77-55.507L358.44 250.75z"/></g></svg>
</span>
</div>
<div class="examplecode"><pre><code class="javascript">
document.addEventListener('DOMContentLoaded', function () {
var variableWidth = document.querySelector('.js_variablewlidth');
lory(variableWidth, {
rewind: true
});
});
</code></pre></div>
<h2>Multiple slides to scroll</h2>
<div class="slider js_multislides multislides">
<div class="frame js_frame">
<ul class="slides js_slides">
<li class="js_slide">1</li>
<li class="js_slide">2</li>
<li class="js_slide">3</li>
<li class="js_slide">4</li>
<li class="js_slide">5</li>
<li class="js_slide">6</li>
<li class="js_slide">7</li>
<li class="js_slide">8</li>
<li class="js_slide">9</li>
<li class="js_slide">10</li>
<li class="js_slide">11</li>
<li class="js_slide">12</li>
</ul>
</div>
<span class="js_prev prev">
<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="0 0 501.5 501.5"><g><path fill="#2E435A" d="M302.67 90.877l55.77 55.508L254.575 250.75 358.44 355.116l-55.77 55.506L143.56 250.75z"/></g></svg>
</span>
<span class="js_next next">
<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="0 0 501.5 501.5"><g><path fill="#2E435A" d="M199.33 410.622l-55.77-55.508L247.425 250.75 143.56 146.384l55.77-55.507L358.44 250.75z"/></g></svg>
</span>
</div>
<div class="examplecode"><pre><code class="javascript">
document.addEventListener('DOMContentLoaded', function () {
var multiSlides = document.querySelector('.js_multislides');
lory(multiSlides, {
infinite: 4,
slidesToScroll: 4
});
});
</code></pre></div>
<h2>Custom easings</h2>
<div class="slider js_ease ease">
<div class="frame js_frame">
<ul class="slides js_slides">
<li class="js_slide">1</li>
<li class="js_slide">2</li>
<li class="js_slide">3</li>
<li class="js_slide">4</li>
<li class="js_slide">5</li>
<li class="js_slide">6</li>
<li class="js_slide">7</li>
<li class="js_slide">8</li>
<li class="js_slide">9</li>
<li class="js_slide">10</li>
<li class="js_slide">11</li>
<li class="js_slide">12</li>
</ul>
</div>
<span class="js_prev prev">
<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="0 0 501.5 501.5"><g><path fill="#2E435A" d="M302.67 90.877l55.77 55.508L254.575 250.75 358.44 355.116l-55.77 55.506L143.56 250.75z"/></g></svg>
</span>
<span class="js_next next">
<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="0 0 501.5 501.5"><g><path fill="#2E435A" d="M199.33 410.622l-55.77-55.508L247.425 250.75 143.56 146.384l55.77-55.507L358.44 250.75z"/></g></svg>
</span>
</div>
<div class="examplecode"><pre><code class="javascript">
document.addEventListener('DOMContentLoaded', function () {
var ease = document.querySelector('.js_ease');
// http://easings.net/
lory(ease, {
infinite: 4,
slidesToScroll: 4,
slideSpeed: 1000,
ease: 'cubic-bezier(0.455, 0.03, 0.515, 0.955)'
});
});
</code></pre></div>
<h2>Showing events</h2>
<div class="slider js_events events">
<div class="frame js_frame">
<ul class="slides js_slides">
<li class="js_slide">1</li>
<li class="js_slide">2</li>
<li class="js_slide">3</li>
<li class="js_slide">4</li>
<li class="js_slide">5</li>
<li class="js_slide">6</li>
</ul>
</div>
<span class="js_prev prev">
<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="0 0 501.5 501.5"><g><path fill="#2E435A" d="M302.67 90.877l55.77 55.508L254.575 250.75 358.44 355.116l-55.77 55.506L143.56 250.75z"/></g></svg>
</span>
<span class="js_next next">
<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="0 0 501.5 501.5"><g><path fill="#2E435A" d="M199.33 410.622l-55.77-55.508L247.425 250.75 143.56 146.384l55.77-55.507L358.44 250.75z"/></g></svg>
</span>
</div>
<code class="events_log"></code>
<div class="examplecode"><pre><code class="javascript">
document.addEventListener('DOMContentLoaded', function () {
var events = document.querySelector('.js_events');
function handleEvent(e) {
var newSpan = document.createElement('span');
var time = new Date();
time = time.getHours() + ':' + time.getMinutes() + ':' + time.getSeconds() + ',' + time.getMilliseconds();
var newContent = document.createTextNode('[' + time + '] Event dispatched: "' + e.type + '"');
newSpan.appendChild(newContent);
e.target.nextElementSibling.appendChild(newSpan);
}
events.addEventListener('before.lory.init', handleEvent);
events.addEventListener('after.lory.init', handleEvent);
events.addEventListener('before.lory.slide', handleEvent);
events.addEventListener('after.lory.slide', handleEvent);
events.addEventListener('before.lory.destroy', handleEvent);
events.addEventListener('after.lory.destroy', handleEvent);
events.addEventListener('on.lory.resize', handleEvent);
events.addEventListener('on.lory.touchend', handleEvent);
events.addEventListener('on.lory.touchmove', handleEvent);
events.addEventListener('on.lory.touchstart', handleEvent);
lory(events, {
infinite: 1
});
});
</code></pre></div>
</section>
<section class="multiplesliders">
<h2>initialize multiple similiar sliders</h2>
<div class="examplecode"><pre><code class="javascript">
'use strict';
document.addEventListener('DOMContentLoaded', function () {
Array.prototype.slice.call(document.querySelectorAll('.js_slider')).forEach(function (element, index) {
lory(element, {});
});
});
</code></pre></div>
</section>
<section class="commonJS">
<h2>Consume it as a commonJS module</h2>
<div class="examplecode"><pre><code class="javascript">
"use strict";
var lory = require('lory.js').lory;
document.addEventListener('DOMContentLoaded', function() {
var slider = document.querySelector('.js_slider');
lory(slider, {
// options going here
});
});
</code></pre></div>
</section>
<section class="ES2015">
<h2>Consume it as an ES2015 module</h2>
<div class="examplecode"><pre><code class="javascript">
import {lory} from 'lory.js';
document.addEventListener('DOMContentLoaded', () => {
const slider = document.querySelector('.js_slider');
lory(slider, {
// options going here
});
});
</code></pre></div>
<section class="jquery">
<h2>Use it as a jQuery Plugin</h2>
<div class="examplecode"><pre><code class="html">
<script src="js/jquery.lory.min.js"></script>
</code></pre></div>
<div class="examplecode"><pre><code class="javascript">
'use strict';
var $elements = $('.js_simple');
$(function() {
$elements.lory({
infinite: 1
});
$elements.data().lory.slideTo(4);
// $elements.data().lory.prev();
// $elements.data().lory.next();
});
</code></pre></div>
</section>
<section class="development">
<h2>Local development</h2>
<div class="examplecode"><pre><code class="shell">
// To install dev dependencies run:
yarn install
// To start the development server run:
yarn run dev
// To lint your code run:
yarn run lint
// To make a full new build run:
yarn run build
</code></pre></div>
</section>
<section class="tests">
<h2>Run tests</h2>
<div class="examplecode"><pre><code class="shell">
// To install dev dependencies run:
yarn install
// To start the karma tests locally run:
yarn run karma-local
</code></pre></div>
<img class="testscreen" src="./static/tests.png" />
</section>
<section class="api">
<h2>Public API</h2>
<table>
<tr>
<th>prev:</th>
<td>slides to the previous slide</td>
</tr>
<tr>
<th>next:</th>
<td>slides to the next slide</td>
</tr>
<tr>
<th>slideTo:</th>
<td>slides to the index given as an argument: (arguments: index {number})</td>
</tr>
<tr>
<th>returnIndex:</th>
<td>returns the index of the current slide element</td>
</tr>
<tr>
<th>setup:</th>
<td>binds eventlisteners, merging default and user options, setup the slides based on DOM (called once during initialisation)</td>
<td>Call setup if DOM or user options have changed or eventlisteners needs to be rebinded.</td>
</tr>
<tr>
<th>reset:</th>
<td>sets the slider back to the starting position and resets the current index (called on Resize event)</td>
</tr>
<tr>
<th>destroy:</th>
<td>unmount/destroy the instance of lory</td>
</tr>
</table>
</section>
<section class="options">
<h2>Options</h2>
<table>
<tr>
<th>slidesToScroll</th>
<td>slides scrolled at once</td>
<td>default: 1</td>
</tr>
<tr>
<th>enableMouseEvents</th>
<td>enabled mouse events</td>
<td>default: false</td>
</tr>
<tr>
<th>infinite</th>
<td>like carousel, works with multiple slides. (do not combine with rewind)</td>
<td>default: false (number of visible slides)</td>
</tr>
<tr>
<th>rewind</th>
<td>if slider reached the last slide, with next click the slider goes back to the startindex. (do not combine with infinite)</td>
<td>default: false</td>
</tr>
<tr>
<th>slideSpeed</th>
<td>time in milliseconds for the animation of a valid slide attempt</td>
<td>default: 300</td>
</tr>
<tr>
<th>rewindSpeed</th>
<td>time in milliseconds for the animation of the rewind after the last slide</td>
<td>default: 600</td>
</tr>
<tr>
<th>snapBackSpeed</th>
<td>time for the snapBack of the slider if the slide attempt was not valid</td>
<td>default: 200</td>
</tr>
<tr>
<td>initialIndex</td>
<td>the slide index to show when the slider is initialized</td>
<td>default: 0</td>
</tr>
<tr>
<th>ease</th>
<td>cubic bezier easing functions: http://easings.net/de</td>
<td>default: 'ease'</td>
</tr>
<tr>
<th>classNameFrame</th>
<td>class name for slider frame</td>
<td>default: 'js_frame'</td>
</tr>
<tr>
<th>classNameSlideContainer</th>
<td>class name for slides container</td>
<td>default: 'js_slides'</td>
</tr>
<tr>
<th>classNamePrevCtrl</th>
<td>class name for slider previous control</td>
<td>default: 'js_prev'</td>
</tr>
<tr>
<th>classNameNextCtrl</th>
<td>class name for slider next control</td>
<td>default: 'js_next'</td>
</tr>
</table>
</section>
<section class="hooks">
<h2>Events</h2>
<table>
<tr>
<th>before.lory.init</th>
<td>fires before initialisation (first in setup function)</td>
</tr>
<tr>
<th>after.lory.init</th>
<td>fires after initialisation (end of setup function)</td>
</tr>
<tr>
<th>before.lory.slide</th>
<td><strong>arguments:</strong> currentSlide, nextSlide</td>
<td>fires before slide change</td>
</tr>
<tr>
<th>after.lory.slide</th>
<td><strong>arguments:</strong> currentSlide</td>
<td>fires after slide change</td>
</tr>
<tr>
<th>before.lory.destroy</th>
<td>fires before the slider instance gets destroyed</td>
</tr>
<tr>
<th>after.lory.destroy</th>
<td>fires after the slider instance gets destroyed</td>
</tr>
<tr>
<th>on.lory.resize</th>
<td>fires on every resize event</td>
</tr>
<tr>
<th>on.lory.touchstart</th>
<td>fires on every slider touchstart event</td>
</tr>
<tr>
<th>on.lory.touchmove</th>
<td>fires on every slider touchmove event</td>
</tr>
<tr>
<th>on.lory.touchend</th>
<td>fires on every slider touchend event</td>
</tr>
</table>
</section>
<footer>
Copyright © 2015 Maximilian Heinz, contributors. Released under the MIT license
</footer>
</body>
<script src="./static/vendor/highlight.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
<script src="./dist/lory.min.js"></script>
<script>
'use strict';
document.addEventListener('DOMContentLoaded', function () {
var simple = document.querySelector('.js_simple');
var simple_dots = document.querySelector('.js_simple_dots');
var dot_count = simple_dots.querySelectorAll('.js_slide').length;
var dot_container = simple_dots.querySelector('.js_dots');
var dot_list_item = document.createElement('li');
var percentage = document.querySelector('.js_percentage');
var rewind = document.querySelector('.js_rewind');
var rewind_percentage = document.querySelector('.js_rewind_percentage');
var variableWidth = document.querySelector('.js_variablewidth');
var multiSlides = document.querySelector('.js_multislides');
var ease = document.querySelector('.js_ease');
var events = document.querySelector('.js_events');
lory(simple, {
infinite: 1,
enableMouseEvents: true
});
function handleDotEvent(e) {
if (e.type === 'before.lory.init') {
for (var i = 0, len = dot_count; i < len; i++) {
var clone = dot_list_item.cloneNode();
dot_container.appendChild(clone);
}
dot_container.childNodes[0].classList.add('active');
}
if (e.type === 'after.lory.init') {
for (var i = 0, len = dot_count; i < len; i++) {
dot_container.childNodes[i].addEventListener('click', function(e) {
dot_navigation_slider.slideTo(Array.prototype.indexOf.call(dot_container.childNodes, e.target));
});
}
}
if (e.type === 'after.lory.slide') {
for (var i = 0, len = dot_container.childNodes.length; i < len; i++) {
dot_container.childNodes[i].classList.remove('active');
}
dot_container.childNodes[e.detail.currentSlide - 1].classList.add('active');
}
if (e.type === 'on.lory.resize') {
for (var i = 0, len = dot_container.childNodes.length; i < len; i++) {
dot_container.childNodes[i].classList.remove('active');
}
dot_container.childNodes[0].classList.add('active');
}
}
simple_dots.addEventListener('before.lory.init', handleDotEvent);
simple_dots.addEventListener('after.lory.init', handleDotEvent);
simple_dots.addEventListener('after.lory.slide', handleDotEvent);
simple_dots.addEventListener('on.lory.resize', handleDotEvent);
var dot_navigation_slider = lory(simple_dots, {
infinite: 1,
enableMouseEvents: true
});
lory(percentage, {
infinite: 1,
enableMouseEvents: true
});
lory(rewind, {
rewind: true,
enableMouseEvents: true
});
lory(rewind_percentage, {
rewind: true,
enableMouseEvents: true
});
lory(variableWidth, {
rewind: true,
enableMouseEvents: true
});
lory(multiSlides, {
infinite: 4,
slidesToScroll: 4,
enableMouseEvents: true
});
lory(ease, {
infinite: 4,
slidesToScroll: 4,
slideSpeed: 300,
ease: 'cubic-bezier(0.455, 0.03, 0.515, 0.955)',
enableMouseEvents: true
});
function handleEvent(e) {
var newSpan = document.createElement('span');
var time = new Date();
time = time.getHours() + ':' + time.getMinutes() + ':' + time.getSeconds() + ',' + time.getMilliseconds();
var newContent = document.createTextNode('[' + time + '] Event dispatched: "' + e.type + '"');
newSpan.appendChild(newContent);
e.target.nextElementSibling.appendChild(newSpan);
}
events.addEventListener('before.lory.init', handleEvent);
events.addEventListener('after.lory.init', handleEvent);
events.addEventListener('before.lory.slide', handleEvent);
events.addEventListener('after.lory.slide', handleEvent);
events.addEventListener('before.lory.destroy', handleEvent);
events.addEventListener('after.lory.destroy', handleEvent);
events.addEventListener('on.lory.resize', handleEvent);
events.addEventListener('on.lory.touchend', handleEvent);
events.addEventListener('on.lory.touchmove', handleEvent);
events.addEventListener('on.lory.touchstart', handleEvent);
lory(events, {
infinite: 1
});
});
</script>
<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-61053578-1', 'auto');
ga('send', 'pageview');
</script>
</html>