UNPKG

4.16 kBMarkdownView Raw
1# Flickity
2
3_Touch, responsive, flickable carousels_
4
5See [flickity.metafizzy.co](https://flickity.metafizzy.co) for complete docs and demos.
6
7## Install
8
9### Download
10
11+ CSS:
12 - [flickity.min.css](https://unpkg.com/flickity@2/dist/flickity.min.css) minified, or
13 - [flickity.css](https://unpkg.com/flickity@2/dist/flickity.css) un-minified
14+ JavaScript:
15 - [flickity.pkgd.min.js](https://unpkg.com/flickity@2/dist/flickity.pkgd.min.js) minified, or
16 - [flickity.pkgd.js](https://unpkg.com/flickity@2/dist/flickity.pkgd.js) un-minified
17
18### CDN
19
20Link directly to Flickity files on [unpkg](https://unpkg.com).
21
22``` html
23<link rel="stylesheet" href="https://unpkg.com/flickity@2/dist/flickity.min.css">
24```
25
26``` html
27<script src="https://unpkg.com/flickity@2/dist/flickity.pkgd.min.js"></script>
28```
29
30### Package managers
31
32Bower: `bower install flickity --save`
33
34npm: `npm install flickity --save`
35
36## License
37
38### Commercial license
39
40If you want to use Flickity to develop commercial sites, themes, projects, and applications, the Commercial license is the appropriate license. With this option, your source code is kept proprietary. Purchase a Flickity Commercial License at [flickity.metafizzy.co](https://flickity.metafizzy.co/#commercial-license)
41
42### Open source license
43
44If you are creating an open source application under a license compatible with the [GNU GPL license v3](https://www.gnu.org/licenses/gpl-3.0.html), you may use Flickity under the terms of the GPLv3.
45
46[Read more about Flickity's license](https://flickity.metafizzy.co/license.html).
47
48## Usage
49
50Flickity works with a container element and a set of child cell elements
51
52``` html
53<div class="carousel">
54 <div class="carousel-cell">...</div>
55 <div class="carousel-cell">...</div>
56 <div class="carousel-cell">...</div>
57 ...
58</div>
59```
60
61### Options
62
63``` js
64var flky = new Flickity( '.gallery', {
65 // options, defaults listed
66
67 accessibility: true,
68 // enable keyboard navigation, pressing left & right keys
69
70 adaptiveHeight: false,
71 // set carousel height to the selected slide
72
73 autoPlay: false,
74 // advances to the next cell
75 // if true, default is 3 seconds
76 // or set time between advances in milliseconds
77 // i.e. `autoPlay: 1000` will advance every 1 second
78
79 cellAlign: 'center',
80 // alignment of cells, 'center', 'left', or 'right'
81 // or a decimal 0-1, 0 is beginning (left) of container, 1 is end (right)
82
83 cellSelector: undefined,
84 // specify selector for cell elements
85
86 contain: false,
87 // will contain cells to container
88 // so no excess scroll at beginning or end
89 // has no effect if wrapAround is enabled
90
91 draggable: '>1',
92 // enables dragging & flicking
93 // if at least 2 cells
94
95 dragThreshold: 3,
96 // number of pixels a user must scroll horizontally to start dragging
97 // increase to allow more room for vertical scroll for touch devices
98
99 freeScroll: false,
100 // enables content to be freely scrolled and flicked
101 // without aligning cells
102
103 friction: 0.2,
104 // smaller number = easier to flick farther
105
106 groupCells: false,
107 // group cells together in slides
108
109 initialIndex: 0,
110 // zero-based index of the initial selected cell
111
112 lazyLoad: true,
113 // enable lazy-loading images
114 // set img data-flickity-lazyload="src.jpg"
115 // set to number to load images adjacent cells
116
117 percentPosition: true,
118 // sets positioning in percent values, rather than pixels
119 // Enable if items have percent widths
120 // Disable if items have pixel widths, like images
121
122 prevNextButtons: true,
123 // creates and enables buttons to click to previous & next cells
124
125 pageDots: true,
126 // create and enable page dots
127
128 resize: true,
129 // listens to window resize events to adjust size & positions
130
131 rightToLeft: false,
132 // enables right-to-left layout
133
134 setGallerySize: true,
135 // sets the height of gallery
136 // disable if gallery already has height set with CSS
137
138 watchCSS: false,
139 // watches the content of :after of the element
140 // activates if #element:after { content: 'flickity' }
141
142 wrapAround: false
143 // at end of cells, wraps-around to first for infinite scrolling
144
145});
146```
147
148---
149
150By [Metafizzy 🌈🐻](https://metafizzy.co)