Skip to content

Commit 7c5665f

Browse files
committed
Fixes & Enhancements
- Added custom paging templates - Stripped ID’s from clones - Added component - Made transitions cleaner
1 parent 496311a commit 7c5665f

8 files changed

+85
-484
lines changed

Makefile

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
build: components slick.js slick.css
3+
@component build --dev
4+
5+
components: component.json
6+
@component install --dev
7+
8+
.PHONY: clean

README.markdown

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ autoplaySpeed | int | 3000 | Auto play change interval
2020
centerMode | boolean | false | Enables centered view with partial prev/next slides. Use with odd numbered slidesToShow counts.
2121
centerPadding | string | '50px' | Side padding when in center mode. (px or %)
2222
cssEase | string | 'ease' | CSS3 easing
23+
customPaging | function | n/a | Custom paging templates. See source for use example.
2324
dots | boolean | false | Current slide indicator dots
2425
draggable | boolean | true | Enables desktop dragging
2526
easing | string | 'linear' | animate() fallback easing

component.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "slick",
3+
"repo": "kenwheeler/slick",
4+
"description": "the last carousel you'll ever need",
5+
"version": "1.3.4",
6+
"keywords": ["ui", "jquery", "carousel", "responsive", "slider"],
7+
"dependencies": {
8+
"component/jquery": "*"
9+
},
10+
"development": {},
11+
"scripts": {
12+
"slick/slick.js": "slick.js"
13+
},
14+
"styles": {
15+
"slick/slick.css": "slick.css"
16+
}
17+
}

index.html

+6
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,12 @@ <h2 >Settings</h2>
453453
<td>'ease'</td>
454454
<td>CSS3 Animation Easing</td>
455455
</tr>
456+
<tr>
457+
<td>customPaging</td>
458+
<td>function</td>
459+
<td>n/a</td>
460+
<td>Custom paging templates. See source for use example.</td>
461+
</tr>
456462
<tr>
457463
<td>dots</td>
458464
<td>boolean</td>

slick/slick.css

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* Slider */
2-
.slick-slider { position: relative; display: block; box-sizing: border-box; -moz-box-sizing: border-box; -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; -ms-touch-action: none; touch-action: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); }
2+
.slick-slider { position: relative; display: block; box-sizing: border-box; -moz-box-sizing: border-box; -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; -ms-touch-action: none; touch-action: none; -webkit-tap-highlight-color: transparent; }
33

44
.slick-list { position: relative; overflow: hidden; display: block; margin: 0; padding: 0; }
55
.slick-list:focus { outline: none; }
@@ -23,9 +23,8 @@
2323

2424
/* Icons */
2525
@font-face { font-family: "slick"; src: url("./fonts/slick.eot"); src: url("./fonts/slick.eot?#iefix") format("embedded-opentype"), url("./fonts/slick.woff") format("woff"), url("./fonts/slick.ttf") format("truetype"), url("./fonts/slick.svg#slick") format("svg"); font-weight: normal; font-style: normal; }
26-
2726
/* Arrows */
28-
.slick-prev, .slick-next { position: absolute; display: block; height: 20px; width: 20px; line-height: 0; font-size: 0; cursor: pointer; background: transparent; color: transparent; top: 50%; margin-top: -10px; padding: 0; border: none; }
27+
.slick-prev, .slick-next { position: absolute; display: block; height: 20px; width: 20px; line-height: 0; font-size: 0; cursor: pointer; background: transparent; color: transparent; top: 50%; margin-top: -10px; padding: 0; border: none; outline: none; }
2928
.slick-prev:focus, .slick-next:focus { outline: none; }
3029
.slick-prev.slick-disabled:before, .slick-next.slick-disabled:before { opacity: 0.25; }
3130

@@ -41,7 +40,8 @@
4140
.slick-slider { margin-bottom: 30px; }
4241

4342
.slick-dots { position: absolute; bottom: -45px; list-style: none; display: block; text-align: center; padding: 0px; width: 100%; }
44-
.slick-dots li { position: relative; display: inline-block; height: 20px; width: 20px; margin: 0px 5px; padding: 0px; }
45-
.slick-dots li a { display: block; height: 20px; width: 20px; outline: none; line-height: 0; font-size: 0; color: transparent; padding: 5px; }
46-
.slick-dots li a:before { position: absolute; top: 0; left: 0; content: '\8226'; width: 20px; height: 20px; font-family: "slick"; font-size: 6px; line-height: 20px; text-align: center; color: black; opacity: 0.25; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
47-
.slick-dots li.slick-active a:before { opacity: 0.75; }
43+
.slick-dots li { position: relative; display: inline-block; height: 20px; width: 20px; margin: 0px 5px; padding: 0px; cursor: pointer; }
44+
.slick-dots li button { border: 0; background: transparent; display: block; height: 20px; width: 20px; outline: none; line-height: 0; font-size: 0; color: transparent; padding: 5px; cursor: pointer; outline: none; }
45+
.slick-dots li button:focus { outline: none; }
46+
.slick-dots li button:before { position: absolute; top: 0; left: 0; content: '\8226'; width: 20px; height: 20px; font-family: "slick"; font-size: 6px; line-height: 20px; text-align: center; color: black; opacity: 0.25; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
47+
.slick-dots li.slick-active button:before { opacity: 0.75; }

slick/slick.js

+34-38
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
4545
centerMode: false,
4646
centerPadding: '50px',
4747
cssEase: 'ease',
48+
customPaging: function(slider, i) {
49+
return '<button type="button">' + (i + 1) + '</button>';
50+
},
4851
dots: false,
4952
draggable: true,
5053
easing: 'linear',
@@ -103,6 +106,7 @@
103106
_.positionProp = null;
104107
_.$slider = $(element);
105108
_.$slidesCache = null;
109+
_.transformType = null;
106110
_.transitionType = null;
107111
_.windowWidth = 0;
108112
_.windowTimer = null;
@@ -259,29 +263,18 @@
259263
Slick.prototype.applyTransition = function(slide) {
260264

261265
var _ = this,
262-
transition, origin;
266+
transition = {};
263267

264268
if (_.options.fade === false) {
265-
transition = _.transitionType + ' ' + _.options.speed + 'ms ' + _.options.cssEase;
269+
transition[_.transitionType] = _.transformType + ' ' + _.options.speed + 'ms ' + _.options.cssEase;
266270
} else {
267-
transition = 'opacity ' + _.options.speed + 'ms ' + _.options.cssEase;
268-
}
269-
270-
if (_.options.vertical === false) {
271-
origin = (_.listWidth / 2) + ' 50%';
272-
} else {
273-
origin = '';
271+
transition[_.transitionType] = 'opacity ' + _.options.speed + 'ms ' + _.options.cssEase;
274272
}
275273

276274
if (_.options.fade === false) {
277-
_.$slideTrack.css({
278-
transition: transition,
279-
transformOrigin: origin
280-
});
275+
_.$slideTrack.css(transition);
281276
} else {
282-
_.$slides.eq(slide).css({
283-
transition: transition
284-
});
277+
_.$slides.eq(slide).css(transition);
285278
}
286279

287280
};
@@ -355,10 +348,10 @@
355348
if (_.options.arrows === true && _.slideCount > _.options.slidesToShow) {
356349

357350
_.$prevArrow = $(
358-
'<button type="button" class="slick-prev" tabIndex="-1">Previous</button>').appendTo(
351+
'<button type="button" class="slick-prev">Previous</button>').appendTo(
359352
_.$slider);
360353
_.$nextArrow = $(
361-
'<button type="button" class="slick-next" tabIndex="-1">Next</button>').appendTo(
354+
'<button type="button" class="slick-next">Next</button>').appendTo(
362355
_.$slider);
363356

364357
if (_.options.infinite !== true) {
@@ -379,8 +372,7 @@
379372
dotString = '<ul class="slick-dots">';
380373

381374
for (i = 0; i <= _.getDotCount(); i += 1) {
382-
dotString += '<li><a href="javascript:void(0)" tabIndex="-1">' + i +
383-
'</a></li>';
375+
dotString += '<li>' + _.options.customPaging.call(this, _, i) + '</li>';
384376
}
385377

386378
dotString += '</ul>';
@@ -415,10 +407,6 @@
415407
'<div class="slick-list"/>').parent();
416408
_.$slideTrack.css('opacity', 0);
417409

418-
if (_.options.accessibility === true) {
419-
_.$list.prop('tabIndex', 0);
420-
}
421-
422410
if (_.options.centerMode === true) {
423411
_.options.infinite = true;
424412
_.options.slidesToScroll = 1;
@@ -435,6 +423,10 @@
435423

436424
_.buildDots();
437425

426+
if (_.options.accessibility === true) {
427+
_.$list.prop('tabIndex', 0);
428+
}
429+
438430
_.setSlideClasses(0);
439431

440432
if (_.options.draggable === true) {
@@ -547,17 +539,15 @@
547539

548540
Slick.prototype.disableTransition = function(slide) {
549541

550-
var _ = this;
542+
var _ = this,
543+
transition = {};
544+
545+
transition[_.transitionType] = "";
551546

552547
if (_.options.fade === false) {
553-
_.$slideTrack.css({
554-
transition: '',
555-
transformOrigin: ''
556-
});
548+
_.$slideTrack.css(transition);
557549
} else {
558-
_.$slides.eq(slide).css({
559-
transition: ''
560-
});
550+
_.$slides.eq(slide).css(transition);
561551
}
562552

563553
};
@@ -720,7 +710,7 @@
720710
var _ = this;
721711

722712
if (_.options.dots === true && _.slideCount > _.options.slidesToShow) {
723-
$('li a', _.$dots).on('click.slick', {
713+
$('li', _.$dots).on('click.slick', {
724714
message: 'index'
725715
}, _.changeSlide);
726716
}
@@ -1135,15 +1125,18 @@
11351125

11361126
if (document.body.style.MozTransform !== undefined) {
11371127
_.animType = 'MozTransform';
1138-
_.transitionType = '-moz-transform';
1128+
_.transformType = "-moz-transform";
1129+
_.transitionType = 'MozTransition';
11391130
}
11401131
if (document.body.style.webkitTransform !== undefined) {
11411132
_.animType = 'webkitTransform';
1142-
_.transitionType = '-webkit-transform';
1133+
_.transformType = "-webkit-transform";
1134+
_.transitionType = 'webkitTransition';
11431135
}
11441136
if (document.body.style.msTransform !== undefined) {
11451137
_.animType = 'msTransform';
1146-
_.transitionType = '-ms-transform';
1138+
_.transformType = "-ms-transform";
1139+
_.transitionType = 'mstransition';
11471140
}
11481141

11491142
_.transformsEnabled = (_.animType !== null);
@@ -1231,14 +1224,17 @@
12311224
for (i = _.slideCount; i > (_.slideCount -
12321225
infiniteCount); i -= 1) {
12331226
slideIndex = i - 1;
1234-
$(_.$slides[slideIndex]).clone().prependTo(
1227+
$(_.$slides[slideIndex]).clone().attr('id', '').prependTo(
12351228
_.$slideTrack).addClass('slick-cloned');
12361229
}
12371230
for (i = 0; i < infiniteCount; i += 1) {
12381231
slideIndex = i;
1239-
$(_.$slides[slideIndex]).clone().appendTo(
1232+
$(_.$slides[slideIndex]).clone().attr('id', '').appendTo(
12401233
_.$slideTrack).addClass('slick-cloned');
12411234
}
1235+
_.$slideTrack.find('.slick-cloned').find('[id]').each(function() {
1236+
$(this).attr('id', '');
1237+
});
12421238

12431239
}
12441240

0 commit comments

Comments
 (0)