1.5.9 • Published 9 years ago

slick-browserify v1.5.9

Weekly downloads
9
License
MIT
Repository
github
Last release
9 years ago

slick

the last carousel you'll ever need

Demo

http://kenwheeler.github.io/slick

CDN

CDN hosted slick is a great way to get set up quick:

In your <head> add:

<link rel="stylesheet" type="text/css" href="//cdn.jsdelivr.net/jquery.slick/1.5.9/slick.css"/>

// Add the slick-theme.css if you want default styling
<link rel="stylesheet" type="text/css" href="//cdn.jsdelivr.net/jquery.slick/1.5.9/slick-theme.css"/>

Then, before your closing <body> tag add:

<script type="text/javascript" src="//cdn.jsdelivr.net/jquery.slick/1.5.9/slick.min.js"></script>

Package Managers

//Bower
bower install --save slick-carousel

//NPM
npm install slick-carousel

Contributing

PLEASE review CONTRIBUTING.markdown prior to requesting a feature, filing a pull request or filing an issue.

Data Attribute Settings

In slick 1.5 you can now add settings using the data-slick attribute. You still need to call $(element).slick() to initialize slick on the element.

Example:

<div data-slick='{"slidesToShow": 4, "slidesToScroll": 4}'>
  <div><h3>1</h3></div>
  <div><h3>2</h3></div>
  <div><h3>3</h3></div>
  <div><h3>4</h3></div>
  <div><h3>5</h3></div>
  <div><h3>6</h3></div>
</div>

Settings

OptionTypeDefaultDescription
accessibilitybooleantrueEnables tabbing and arrow key navigation
autoplaybooleanfalseEnables auto play of slides
autoplaySpeedint3000Auto play change interval
centerModebooleanfalseEnables centered view with partial prev/next slides. Use with odd numbered slidesToShow counts.
centerPaddingstring'50px'Side padding when in center mode. (px or %)
cssEasestring'ease'CSS3 easing
customPagingfunctionn/aCustom paging templates. See source for use example.
dotsbooleanfalseCurrent slide indicator dots
dotsClassstring'slick-dots'Class for slide indicator dots container
draggablebooleantrueEnables desktop dragging
easingstring'linear'animate() fallback easing
edgeFrictioninteger0.15Resistance when swiping edges of non-infinite carousels
fadebooleanfalseEnables fade
arrowsbooleantrueEnable Next/Prev arrows
appendArrowsstring$(element)Change where the navigation arrows are attached (Selector, htmlString, Array, Element, jQuery object)
appendDotsstring$(element)Change where the navigation dots are attached (Selector, htmlString, Array, Element, jQuery object)
mobileFirstbooleanfalseResponsive settings use mobile first calculation
prevArrowstring (htmljQuery selector)object (DOM nodejQuery object)PreviousAllows you to select a node or customize the HTML for the "Previous" arrow.
nextArrowstring (htmljQuery selector)object (DOM nodejQuery object)NextAllows you to select a node or customize the HTML for the "Next" arrow.
infinitebooleantrueInfinite looping
initialSlideinteger0Slide to start on
lazyLoadstring'ondemand'Accepts 'ondemand' or 'progressive' for lazy load technique
pauseOnHoverbooleantruePauses autoplay on hover
pauseOnDotsHoverbooleanfalsePauses autoplay when a dot is hovered
respondTostring'window'Width that responsive object responds to. Can be 'window', 'slider' or 'min' (the smaller of the two).
responsiveobjectnullObject containing breakpoints and settings objects (see demo). Enables settings sets at given screen width. Set settings to "unslick" instead of an object to disable slick at a given breakpoint.
rowsint1Setting this to more than 1 initializes grid mode. Use slidesPerRow to set how many slides should be in each row.
slidestring''Slide element query
slidesPerRowint1With grid mode intialized via the rows option, this sets how many slides are in each grid row.
slidesToShowint1# of slides to show at a time
slidesToScrollint1# of slides to scroll at a time
speedint300Transition speed
swipebooleantrueEnables touch swipe
swipeToSlidebooleanfalseSwipe to slide irrespective of slidesToScroll
touchMovebooleantrueEnables slide moving with touch
touchThresholdint5To advance slides, the user must swipe a length of (1/touchThreshold) * the width of the slider.
useCSSbooleantrueEnable/Disable CSS Transitions
useTransformbooleanfalseEnable/Disable CSS Transforms
variableWidthbooleanfalseDisables automatic slide width calculation
verticalbooleanfalseVertical slide direction
verticalSwipingbooleanfalseChanges swipe direction to vertical
rtlbooleanfalseChange the slider's direction to become right-to-left
waitForAnimatebooleantrueIgnores requests to advance the slide while animating
zIndexnumber1000Set the zIndex values for slides, useful for IE9 and lower

Events

In slick 1.4, callback methods have been deprecated and replaced with events. Use them before the initialization of slick as shown below:

// On swipe event
$('.your-element').on('swipe', function(event, slick, direction){
  console.log(direction);
  // left
});

// On edge hit
$('.your-element').on('edge', function(event, slick, direction){
  console.log('edge was hit')
});

// On before slide change
$('.your-element').on('beforeChange', function(event, slick, currentSlide, nextSlide){
  console.log(nextSlide);
});
EventParamsDescription
afterChangeevent, slick, currentSlideAfter slide change callback
beforeChangeevent, slick, currentSlide, nextSlideBefore slide change callback
breakpointevent, slick, breakpointFires after a breakpoint is hit
destroyevent, slickWhen slider is destroyed, or unslicked.
edgeevent, slick, directionFires when an edge is overscrolled in non-infinite mode.
initevent, slickWhen Slick initializes for the first time callback. Note that this event should be defined before initializing the slider.
reInitevent, slickEvery time Slick (re-)initializes callback
setPositionevent, slickEvery time Slick recalculates position
swipeevent, slick, directionFires after swipe/drag

Methods

Methods are called on slick instances through the slick method itself in version 1.4, see below:

// Add a slide
$('.your-element').slick('slickAdd',"<div></div>");

// Get the current slide
var currentSlide = $('.your-element').slick('slickCurrentSlide');

This new syntax allows you to call any internal slick method as well:

// Manually refresh positioning of slick
$('.your-element').slick('setPosition');
MethodArgumentDescription
slickoptions : objectInitializes Slick
unslickDestroys Slick
slickNextTriggers next slide
slickPrevTriggers previous slide
slickPausePause Autoplay
slickPlayStart Autoplay
slickGoToindex : int, dontAnimate : boolGoes to slide by index, skipping animation if second parameter is set to true
slickCurrentSlideReturns the current slide index
slickAddelement : html or DOM object, index: int, addBefore: boolAdd a slide. If an index is provided, will add at that index, or before if addBefore is set. If no index is provided, add to the end or to the beginning if addBefore is set. Accepts HTML StringObject
slickRemoveindex: int, removeBefore: boolRemove slide by index. If removeBefore is set true, remove slide preceding index, or the first slide if no index is specified. If removeBefore is set to false, remove the slide following index, or the last slide if no index is set.
slickFilterfilter : selector or functionFilters slides using jQuery .filter syntax
slickUnfilterRemoves applied filter
slickGetOptionoption : string(option name)Gets an option value.
slickSetOptionoption : string(option name), value : depends on option, refresh : booleanSets an option live. Set refresh to true if it is an option that changes the display

Example

Initialize with:

$(element).slick({
  dots: true,
  speed: 500
});

Destroy with:

$(element).slick('unslick');

Sass Variables

VariableTypeDefaultDescription
$slick-font-pathstring"./fonts/"Directory path for the slick icon font
$slick-font-familystring"slick"Font-family for slick icon font
$slick-loader-pathstring"./"Directory path for the loader image
$slick-arrow-colorcolorwhiteColor of the left/right arrow icons
$slick-dot-colorcolorblackColor of the navigation dots
$slick-dot-color-activecolor$slick-dot-colorColor of the active navigation dot
$slick-prev-characterstring'\2190'Unicode character code for the previous arrow icon
$slick-next-characterstring'\2192'Unicode character code for the next arrow icon
$slick-dot-characterstring'\2022'Unicode character code for the navigation dot icon
$slick-dot-sizepixels6pxSize of the navigation dots

Dependencies

jQuery 1.7

License

Copyright (c) 2014 Ken Wheeler

Licensed under the MIT license.

Free as in Bacon.