├── .eslintrc.js ├── .gitignore ├── .jshintignore ├── .jshintrc ├── .nvmrc ├── .tm_properties ├── README.md ├── assets ├── _redirects ├── favicon.ico └── img │ └── flickity-illustration.png ├── bower.json ├── content ├── 404.hbs ├── api.hbs ├── events.hbs ├── extras.hbs ├── index.hbs ├── license.hbs ├── options.hbs └── style.hbs ├── css ├── base.css ├── syntax-highlight.css └── web-fonts.css ├── data ├── fullscreen_images.json ├── in_use.json └── licenses.json ├── gulpfile.js ├── js ├── .eslintrc.js ├── boilerplate.js └── init.js ├── modules ├── .eslintrc.js ├── big-links │ ├── big-link.css │ └── big-links.hbs ├── call-out │ ├── call-out.css │ └── fullscreen-call-out.hbs ├── carousel │ └── carousel.css ├── demos │ ├── append │ │ ├── append.hbs │ │ └── append.js │ ├── arrow-wiz │ │ ├── arrow-wiz.css │ │ ├── arrow-wiz.hbs │ │ └── arrow-wiz.js │ ├── as-nav-for │ │ ├── as-nav-for.css │ │ └── as-nav-for.hbs │ ├── auto-play │ │ └── auto-play.hbs │ ├── cell-align │ │ └── cell-align.hbs │ ├── cell-selector │ │ ├── cell-selector.css │ │ └── cell-selector.hbs │ ├── contain │ │ └── contain.hbs │ ├── custom-nav │ │ ├── custom-nav.hbs │ │ └── custom-nav.js │ ├── destroy │ │ ├── destroy.hbs │ │ └── destroy.js │ ├── events-table │ │ ├── events-table.css │ │ ├── events-table.hbs │ │ └── events-table.js │ ├── free-scroll │ │ └── free-scroll.hbs │ ├── fullscreen │ │ ├── fullscreen.css │ │ ├── view-fullscreen-demo.hbs │ │ └── view-fullscreen-demo.js │ ├── imagesloaded │ │ └── imagesloaded.hbs │ ├── insert │ │ └── insert.js │ ├── keyhole │ │ ├── keyhole-content.hbs │ │ ├── keyhole.css │ │ ├── keyhole.hbs │ │ └── keyhole.js │ ├── lazy-load │ │ ├── lazy-cell-images.hbs │ │ ├── lazy-load.css │ │ └── lazy-srcset-images.hbs │ ├── line-dots │ │ ├── line-dots.css │ │ └── line-dots.hbs │ ├── next │ │ ├── next.hbs │ │ └── next.js │ ├── o-dots │ │ ├── o-dots.css │ │ └── o-dots.hbs │ ├── parallax │ │ ├── parallax.css │ │ ├── parallax.hbs │ │ └── parallax.js │ ├── player │ │ ├── player.hbs │ │ └── player.js │ ├── prepend │ │ ├── prepend.hbs │ │ └── prepend.js │ ├── prev-next-big-arrow │ │ ├── prev-next-big-arrow.css │ │ └── prev-next-big-arrow.hbs │ ├── prev-next-small-outside │ │ ├── prev-next-small-outside.css │ │ └── prev-next-small-outside.hbs │ ├── previous │ │ ├── previous.hbs │ │ └── previous.js │ ├── progress-bar │ │ ├── progress-bar.css │ │ ├── progress-bar.hbs │ │ └── progress-bar.js │ ├── remove │ │ ├── remove.hbs │ │ └── remove.js │ ├── reposition │ │ ├── reposition.css │ │ ├── reposition.hbs │ │ └── reposition.js │ ├── resize-show │ │ ├── resize-show.hbs │ │ └── resize-show.js │ ├── resize │ │ ├── resize.css │ │ ├── resize.hbs │ │ └── resize.js │ ├── select-cell-selector │ │ ├── select-cell-selector.hbs │ │ └── select-cell-selector.js │ ├── select-cell │ │ ├── select-cell.hbs │ │ └── select-cell.js │ ├── select-instant │ │ ├── select-instant.hbs │ │ └── select-instant.js │ ├── select │ │ ├── select.hbs │ │ └── select.js │ ├── static-click │ │ ├── static-click.css │ │ ├── static-click.hbs │ │ └── static-click.js │ ├── watch-css │ │ ├── watch-css.css │ │ └── watch-css.hbs │ └── wrap-around │ │ └── wrap-around.hbs ├── example │ └── example.css ├── fizzy-docs-modules-overwrites │ ├── button.css │ ├── buy-button.css │ ├── chunky-button.css │ └── site-footer.css ├── hero-carousel │ ├── hero-carousel.css │ ├── hero-carousel.hbs │ └── hero-carousel.js ├── in-use-carousel │ ├── in-use-carousel.css │ └── in-use-carousel.hbs ├── page-nav │ ├── page-nav.css │ ├── page-nav.js │ └── stickeroo.js └── site-nav │ ├── site-nav.css │ └── site-nav.hbs ├── package-lock.json ├── package.json ├── tasks ├── assets.js ├── content.js ├── css.js ├── dist.js ├── js.js └── utils │ ├── get-glob-paths.js │ ├── highlight-code-block.js │ └── page-nav.js └── templates └── page.hbs /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: [ 'metafizzy' ], 3 | extends: 'plugin:metafizzy/node', 4 | env: { 5 | node: true, 6 | }, 7 | parserOptions: { 8 | ecmaVersion: 2018, 9 | }, 10 | globals: { 11 | }, 12 | rules: { 13 | 'prefer-object-spread': 'error', 14 | }, 15 | ignorePatterns: [ 16 | 'bower_components', 17 | ], 18 | }; 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | bower_components/ 3 | build/ 4 | lib/ 5 | fonts/ 6 | *.mp4 7 | *.gif 8 | assets/img/in-use/ 9 | .netlify 10 | .vercel 11 | -------------------------------------------------------------------------------- /.jshintignore: -------------------------------------------------------------------------------- 1 | bower_components 2 | node_modules 3 | build 4 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "node": true, 3 | "undef": true, 4 | "unused": true 5 | } 6 | -------------------------------------------------------------------------------- /.nvmrc: -------------------------------------------------------------------------------- 1 | 16 -------------------------------------------------------------------------------- /.tm_properties: -------------------------------------------------------------------------------- 1 | softTabs = true 2 | tabSize = 2 3 | excludeInFileChooser = "{$exclude,build,components,bower_components,node_modules}" 4 | excludeInFolderSearch = "{$exclude,build,components,bower_components,node_modules}" 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Flickity docs 2 | 3 | Documentation for Flickity, the web UI library for touch, responsive, flickable carousels. 4 | 5 | [flickity.metafizzy.co](https://flickity.metafizzy.co) or [flickityjs.com](https://flickityjs.com) 6 | 7 | ## Build 8 | 9 | Building these docs requires [npm](https://npmjs.com), [Bower](http://bower.io), and [Gulp](http://gulpjs.com/). 10 | 11 | ``` bash 12 | npm install 13 | bower install 14 | npx gulp 15 | ``` 16 | 17 | This will build the docs in `build/`. 18 | 19 | Watch for updates to rebuild docs on the fly. 20 | 21 | ``` bash 22 | gulp dev 23 | ``` 24 | 25 | --- 26 | 27 | By [Metafizzy](http://metafizzy.co) 28 | -------------------------------------------------------------------------------- /assets/_redirects: -------------------------------------------------------------------------------- 1 | /v1/* https://flickity-v1.metafizzy.co/:splat 2 | -------------------------------------------------------------------------------- /assets/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/metafizzy/flickity-docs/73c0a4565c31c3e1a77e29a6dc71fe4ecc65c7c1/assets/favicon.ico -------------------------------------------------------------------------------- /assets/img/flickity-illustration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/metafizzy/flickity-docs/73c0a4565c31c3e1a77e29a6dc71fe4ecc65c7c1/assets/img/flickity-illustration.png -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "flickity-docs", 3 | "version": "2.1.0", 4 | "description": "Documentation for Flickity", 5 | "main": "content/index.html", 6 | "license": "BY-CC", 7 | "private": true, 8 | "ignore": [ 9 | "**/.*", 10 | "node_modules", 11 | "bower_components", 12 | "test", 13 | "tests" 14 | ], 15 | "dependencies": { 16 | "flickity": "^2.2.0", 17 | "flickity-imagesloaded": "^2.0.0", 18 | "flickity-as-nav-for": "^2.0.0", 19 | "flickity-bg-lazyload": "^1.0.0", 20 | "flickity-hash": "^1.0.0", 21 | "flickity-fullscreen": "^1.0.0", 22 | "flickity-fade": "^1.0.0", 23 | "normalize.css": "^8.0.0", 24 | "fizzy-ui-utils": "^2.0.0", 25 | "draggabilly": "^2.1.1", 26 | "fizzy-docs-modules": "metafizzy/fizzy-docs-modules" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /content/404.hbs: -------------------------------------------------------------------------------- 1 | --- 2 | title: Page not found 3 | is_404: true 4 | --- 5 | 6 |

Sorry about that!

7 | 8 |

Is a page or file supposed to be here? 9 | Report missing stuff.

10 | 11 |

Keanu

12 | -------------------------------------------------------------------------------- /content/api.hbs: -------------------------------------------------------------------------------- 1 | --- 2 | title: API 3 | --- 4 | 5 |

Methods

6 | 7 |

Methods are actions done by Flickity instances.

8 | 9 |

With jQuery, methods follow the jQuery UI pattern 10 | $carousel.flickity( 'methodName' /*, arguments */ ).

11 | 12 | ``` js 13 | var $carousel = $('.carousel').flickity() 14 | .flickity('next') 15 | .flickity( 'select', 4 ); 16 | ``` 17 | 18 |
19 |

jQuery chaining is broken by methods that return values like getCellElements.

20 |
21 | 22 |

Vanilla JavaScript methods look like 23 | flickity.methodName( /* arguments */ ). Unlike jQuery methods, they cannot be chained together.

24 | 25 | ``` js 26 | // vanilla JS 27 | var flkty = new Flickity('.carousel'); 28 | flkty.next(); 29 | flkty.select( 3 ); 30 | ``` 31 | 32 |

Selecting slides

33 | 34 |

select

35 | 36 |

Select a slide.

37 | 38 | ``` js 39 | // jQuery 40 | $carousel.flickity( 'select', index, isWrapped, isInstant ) 41 | ``` 42 | ``` js 43 | // vanilla JS 44 | flkty.select( index, isWrapped, isInstant ) 45 | ``` 46 | 47 |

48 | index 49 | Integer 50 | Zero-based index of the slide to select. 51 |

52 |

53 | isWrapped 54 | Boolean 55 | Optional. If true, the last slide will be selected if at the first slide. 56 |

57 |

58 | isInstant 59 | Boolean 60 | If true, immediately view the selected slide without animation. 61 |

62 | 63 |
64 |
65 | ``` js 66 | $('.button-group').on( 'click', '.button', function() { 67 | var index = $(this).index(); 68 | $carousel.flickity( 'select', index ); 69 | }); 70 | ``` 71 |
72 | {{> select }} 73 |
74 | 75 |
76 |
77 | ``` js 78 | // select cell instantly, without animation 79 | $('.button-group').on( 'click', '.button', function() { 80 | var index = $(this).index(); 81 | $carousel.flickity( 'select', index, false, true ); 82 | }); 83 | ``` 84 |
85 | {{> select-instant }} 86 |
87 | 88 | {{! ----------------------------------------------------------------- }} 89 | 90 |

previous

91 | 92 |

Select the previous slide.

93 | 94 | ``` js 95 | // jQuery 96 | $carousel.flickity( 'previous', isWrapped, isInstant ) 97 | ``` 98 | ``` js 99 | // vanilla JS 100 | flkty.previous( isWrapped, isInstant ) 101 | ``` 102 | 103 |

104 | isWrapped 105 | Boolean 106 | Optional. If true, the last slide will be selected if at the first slide. 107 |

108 |

109 | isInstant 110 | Boolean 111 | If true, immediately view the selected slide without animation. 112 |

113 | 114 |
115 |
116 | ``` js 117 | // previous 118 | $('.button--previous').on( 'click', function() { 119 | $carousel.flickity('previous'); 120 | }); 121 | // previous wrapped 122 | $('.button--previous-wrapped').on( 'click', function() { 123 | $carousel.flickity( 'previous', true ); 124 | }); 125 | ``` 126 |
127 | {{> previous }} 128 |
129 | 130 | {{! ----------------------------------------------------------------- }} 131 | 132 |

next

133 | 134 |

Select the next slide.

135 | 136 | ``` js 137 | // jQuery 138 | $carousel.flickity( 'next', isWrapped, isInstant ) 139 | ``` 140 | ``` js 141 | // vanilla JS 142 | flkty.next( isWrapped, isInstant ) 143 | ``` 144 | 145 |

146 | isWrapped 147 | Boolean 148 | Optional. If true, the first slide will be selected if at the last slide. 149 |

150 |

151 | isInstant 152 | Boolean 153 | If true, immediately view the selected slide without animation. 154 |

155 | 156 |
157 |
158 | ``` js 159 | // next 160 | $('.button--next').on( 'click', function() { 161 | $carousel.flickity('next'); 162 | }); 163 | // next wrapped 164 | $('.button--next-wrapped').on( 'click', function() { 165 | $carousel.flickity( 'next', true ); 166 | }); 167 | ``` 168 |
169 | {{> next }} 170 |
171 | 172 | {{! ----------------------------------------------------------------- }} 173 | 174 |

selectCell

175 | 176 |

Select a slide of a cell. Useful for groupCells.

177 | 178 | ``` js 179 | // jQuery 180 | $carousel.flickity( 'selectCell', value, isWrapped, isInstant ) 181 | ``` 182 | ``` js 183 | // vanilla JS 184 | flkty.selectCell( value, isWrapped, isInstant ) 185 | ``` 186 | 187 |

188 | value 189 | Integer or selector String 190 | Zero-based index OR selector string of the cell to select. 191 |

192 |

193 | isWrapped 194 | Boolean 195 | Optional. If true, the last slide will be selected if at the first slide. 196 |

197 |

198 | isInstant 199 | Boolean 200 | If true, immediately view the selected slide without animation. 201 |

202 | 203 |
204 |
205 | ``` js 206 | $('.button-group').on( 'click', '.button', function() { 207 | var index = $(this).index(); 208 | $carousel.flickity( 'selectCell', index ); 209 | }); 210 | ``` 211 |
212 | {{> select-cell }} 213 |
214 | 215 |

You can select a cell with a selector string.

216 | 217 |
218 |
219 | ``` html 220 | 226 | ``` 227 | 228 | ``` js 229 | $carousel.flickity( 'selectCell', '.cell2' ); 230 | ``` 231 |
232 | {{> select-cell-selector }} 233 |
234 | 235 | {{! ----------------------------------------------------------------- }} 236 | 237 |

Sizing and positioning

238 | 239 | {{! ----------------------------------------------------------------- }} 240 | 241 |

resize

242 | 243 |

Resize the carousel and re-position cells.

244 | 245 | ``` js 246 | // jQuery 247 | $carousel.flickity('resize') 248 | ``` 249 | ``` js 250 | // vanilla JS 251 | flkty.resize() 252 | ``` 253 | 254 |
255 |
256 |
257 |
258 | ``` js 259 | $('.button--resize').on( 'click', function() { 260 | // expand carousel by toggling class 261 | $carousel.toggleClass('is-expanded') 262 | .flickity('resize'); 263 | }); 264 | ``` 265 |
266 |
267 | ``` css 268 | .carousel { width: 50%; } 269 | .carousel.is-expanded { width: 100%; } 270 | 271 | .carousel.is-expanded .carousel-cell { 272 | height: 320px; 273 | } 274 | ``` 275 |
276 |
277 | 278 |
279 | {{> resize }} 280 |
281 | 282 |

If Flickity is initialized when hidden, like within a tab, trigger resize after it is shown so cells are properly measured and positioned.

283 | 284 |
285 |
286 | ``` js 287 | $('.button').on( 'click', function() { 288 | $carousel.show() 289 | // resize after un-hiding Flickity 290 | .flickity('resize'); 291 | }); 292 | ``` 293 |
294 | {{> resize-show }} 295 |
296 | 297 | {{! ----------------------------------------------------------------- }} 298 | 299 |

reposition

300 | 301 |

Position cells at selected position. Trigger reposition after the size of a cell has been changed.

302 | 303 | ``` js 304 | // jQuery 305 | $carousel.flickity('reposition') 306 | ``` 307 | ``` js 308 | // vanilla JS 309 | flkty.reposition() 310 | ``` 311 | 312 |
313 |
314 | ``` js 315 | $carousel.on( 'staticClick', function( event, pointer, cellElement, cellIndex ) { 316 | if ( !cellElement ) { 317 | return; 318 | } 319 | $( cellElement ).toggleClass('is-expanded'); 320 | $carousel.flickity('reposition'); 321 | }); 322 | ``` 323 |
324 | {{> reposition }} 325 |
326 | 327 | 328 | {{! ----------------------------------------------------------------- }} 329 | 330 |

Adding and removing cells

331 | 332 |

prepend

333 | 334 |

Prepend elements and create cells to the beginning of the carousel.

335 | 336 | ``` js 337 | // jQuery 338 | $carousel.flickity( 'prepend', elements ) 339 | ``` 340 | ``` js 341 | // vanilla JS 342 | flkty.prepend( elements ) 343 | ``` 344 | 345 |

346 | elements 347 | jQuery object, Array of Elements, Element, or NodeList 348 |

349 | 350 |
351 |
352 | ``` js 353 | $('.button').on( 'click', function() { 354 | var $cellElems = $(''); 355 | $carousel.flickity( 'prepend', $cellElems ); 356 | }); 357 | ``` 358 |
359 | {{> prepend }} 360 |
361 | 362 | {{! ----------------------------------------------------------------- }} 363 | 364 |

append

365 | 366 |

Append elements and create cells to the end of the carousel.

367 | 368 | ``` js 369 | // jQuery 370 | $carousel.flickity( 'append', elements ) 371 | ``` 372 | ``` js 373 | // vanilla JS 374 | flkty.append( elements ) 375 | ``` 376 | 377 |

378 | elements 379 | jQuery object, Array of Elements, Element, or NodeList 380 |

381 | 382 |
383 |
384 | ``` js 385 | $('.button').on( 'click', function() { 386 | var $cellElems = $(''); 387 | $carousel.flickity( 'append', $cellElems ); 388 | }); 389 | ``` 390 |
391 | {{> append }} 392 |
393 | 394 | {{! ----------------------------------------------------------------- }} 395 | 396 |

insert

397 | 398 |

Insert elements into the carousel and create cells.

399 | 400 | ``` js 401 | // jQuery 402 | $carousel.flickity( 'insert', elements, index ) 403 | ``` 404 | ``` js 405 | // vanilla JS 406 | flkty.insert( elements, index ) 407 | ``` 408 | 409 |

410 | elements 411 | jQuery object, Array of Elements, Element, or NodeList 412 |

413 | 414 |

415 | index 416 | Integer 417 | Zero-based index to insert elements. 418 |

419 | 420 |
421 |
422 | ``` js 423 | $('.button').on( 'click', function() { 424 | var $cellElems = $(''); 425 | $carousel.flickity( 'insert', $cellElems, 1 ); 426 | }); 427 | ``` 428 |
429 |
430 |
431 | 432 |
433 | 444 | {{> edit-demo default="YPeNYj" vanillaJS="EaQZQv" }} 445 |
446 |
447 | 448 | {{! ----------------------------------------------------------------- }} 449 | 450 |

remove

451 | 452 |

Remove cells from carousel and remove elements from DOM.

453 | 454 | ``` js 455 | // jQuery 456 | $carousel.flickity( 'remove', elements ) 457 | ``` 458 | ``` js 459 | // vanilla JS 460 | flkty.remove( elements ) 461 | ``` 462 | 463 |

464 | elements 465 | jQuery object, Array of Elements, Element, or NodeList 466 |

467 | 468 |
469 |
470 | ``` js 471 | $('.carousel').on( 'staticClick', function( event, pointer, cellElement, cellIndex ) { 472 | if ( cellElement ) { 473 | $carousel.flickity( 'remove', cellElement ); 474 | } 475 | }); 476 | ``` 477 |
478 | {{> remove }} 479 |
480 | 481 | {{! ----------------------------------------------------------------- }} 482 | 483 |

Player

484 | 485 |

Control autoPlay behavior.

486 | 487 | {{> player }} 488 | 489 | {{! ----------------------------------------------------------------- }} 490 | 491 |

playPlayer

492 | 493 |

Starts auto-play.

494 | 495 |

Setting autoPlay will automatically start auto-play on initialization. You do not need to start auto-play with playPlayer.

496 | 497 | ``` js 498 | // jQuery 499 | $carousel.flickity('playPlayer') 500 | ``` 501 | ``` js 502 | // vanilla JS 503 | flkty.playPlayer() 504 | ``` 505 | 506 | {{! ----------------------------------------------------------------- }} 507 | 508 |

stopPlayer

509 | 510 |

Stops auto-play and cancels pause.

511 | 512 | ``` js 513 | // jQuery 514 | $carousel.flickity('stopPlayer') 515 | ``` 516 | ``` js 517 | // vanilla JS 518 | flkty.stopPlayer() 519 | ``` 520 | 521 | {{! ----------------------------------------------------------------- }} 522 | 523 |

pausePlayer

524 | 525 |

Pauses auto-play.

526 | 527 | ``` js 528 | // jQuery 529 | $carousel.flickity('pausePlayer') 530 | ``` 531 | ``` js 532 | // vanilla JS 533 | flkty.pausePlayer() 534 | ``` 535 | 536 | {{! ----------------------------------------------------------------- }} 537 | 538 |

unpausePlayer

539 | 540 |

Resumes auto-play if paused.

541 | 542 | ``` js 543 | // jQuery 544 | $carousel.flickity('unpausePlayer') 545 | ``` 546 | ``` js 547 | // vanilla JS 548 | flkty.unpausePlayer() 549 | ``` 550 | 551 | {{! ----------------------------------------------------------------- }} 552 | 553 |

Fullscreen

554 | 555 | {{> fullscreen-call-out }} 556 | 557 | {{! ----------------------------------------------------------------- }} 558 | 559 |

viewFullscreen

560 | 561 |

Expand carousel to fullscreen.

562 | 563 | ``` js 564 | // jQuery 565 | $carousel.flickity('viewFullscreen') 566 | ``` 567 | ``` js 568 | // vanilla JS 569 | flkty.viewFullscreen(); 570 | ``` 571 | 572 |
573 |
574 | ``` js 575 | $('.button').on( 'click', function() { 576 | $carousel.flickity('viewFullscreen'); 577 | }); 578 | ``` 579 |
580 | {{> view-fullscreen-demo }} 581 |
582 | 583 | 584 | {{! ----------------------------------------------------------------- }} 585 | 586 |

exitFullscreen

587 | 588 |

Collapse carousel from fullscreen back to normal size & position.

589 | 590 | ``` js 591 | // jQuery 592 | $carousel.flickity('exitFullscreen') 593 | ``` 594 | ``` js 595 | // vanilla JS 596 | flkty.exitFullscreen(); 597 | ``` 598 | 599 | {{! ----------------------------------------------------------------- }} 600 | 601 |

toggleFullscreen

602 | 603 |

Expand or collapse carousel fullscreen view.

604 | 605 | ``` js 606 | // jQuery 607 | $carousel.flickity('toggleFullscreen') 608 | ``` 609 | ``` js 610 | // vanilla JS 611 | flkty.toggleFullscreen(); 612 | ``` 613 | 614 | {{! ----------------------------------------------------------------- }} 615 | 616 |

Utilities

617 | 618 | {{! ----------------------------------------------------------------- }} 619 | 620 |

destroy

621 | 622 |

Remove Flickity functionality completely. destroy will return the element back to its pre-initialized state.

623 | 624 | ``` js 625 | // jQuery 626 | $carousel.flickity('destroy') 627 | ``` 628 | ``` js 629 | // vanilla JS 630 | flkty.destroy() 631 | ``` 632 | 633 |
634 |
635 | ``` js 636 | var $carousel = $('.carousel').flickity(); 637 | var isFlickity = true; 638 | // toggle Flickity on/off 639 | $('.button--toggle').on( 'click', function() { 640 | if ( isFlickity ) { 641 | // destroy Flickity 642 | $carousel.flickity('destroy'); 643 | } else { 644 | // init new Flickity 645 | $carousel.flickity(); 646 | } 647 | isFlickity = !isFlickity; 648 | }); 649 | ``` 650 |
651 | {{> destroy }} 652 |
653 | 654 | 655 | {{! ----------------------------------------------------------------- }} 656 | 657 |

reloadCells

658 | 659 |

Re-collect all cell elements in flickity-slider.

660 | 661 | ``` js 662 | // jQuery 663 | $carousel.flickity('reloadCells') 664 | ``` 665 | ``` js 666 | // vanilla JS 667 | flkty.reloadCells() 668 | ``` 669 | 670 | {{! ----------------------------------------------------------------- }} 671 | 672 |

getCellElements

673 | 674 |

Get the elements of the cells.

675 | 676 | ``` js 677 | // jQuery 678 | var cellElements = $carousel.flickity('getCellElements') 679 | ``` 680 | ``` js 681 | // vanilla JS 682 | var cellElements = flkty.getCellElements() 683 | ``` 684 | 685 |

686 | cellElements 687 | Array of Elements 688 |

689 | 690 | {{! ----------------------------------------------------------------- }} 691 | 692 |

jQuery.fn.data('flickity')

693 | 694 |

Get the Flickity instance from a jQuery object. Flickity instances are useful to access Flickity properties.

695 | 696 | ``` js 697 | var flkty = $('.carousel').data('flickity') 698 | // access Flickity properties 699 | console.log( 'carousel at ' + flkty.selectedIndex ) 700 | ``` 701 | 702 | {{! ----------------------------------------------------------------- }} 703 | 704 |

Flickity.data()

705 | 706 |

Get the Flickity instance via its element. Flickity.data() is useful for getting the Flickity instance in JavaScript, after it has been initalized in HTML.

707 | 708 | ``` js 709 | var flkty = Flickity.data( element ) 710 | ``` 711 | 712 |

713 | element 714 | Element or Selector String 715 |

716 |

717 | flkty 718 | Flickity 719 |

720 | 721 |
722 |
723 | ``` html 724 | 725 | 726 | ``` 727 | 728 | ``` js 729 | // jQuery 730 | // pass in the element, $element[0], not the jQuery object 731 | var flkty = Flickity.data( $('.main-carousel')[0] ) 732 | // vanilla JS 733 | var carousel = document.querySelector('.main-carousel') 734 | var flkty = Flickity.data( carousel ) 735 | // using a selector string 736 | var flkty = Flickity.data('.main-carousel') 737 | ``` 738 |
739 |
740 | 741 | {{! ----------------------------------------------------------------- }} 742 | 743 |

Flickity.setJQuery()

744 | 745 |

Set jQuery for internal use in Flickity. Useful for using Flickity with jQuery and Webpack or Browserify.

746 | 747 | ``` js 748 | Flickity.setJQuery( $ ) 749 | ``` 750 | 751 |

752 | $ 753 | jQuery 754 |

755 | 756 | ``` js 757 | var $ = require('jquery'); 758 | var jQueryBridget = require('jquery-bridget'); 759 | var Flickity = require('flickity'); 760 | 761 | // make Flickity a jQuery plugin 762 | Flickity.setJQuery( $ ); 763 | jQueryBridget( 'flickity', Flickity, $ ); 764 | // now you can use $().flickity() 765 | var $carousel = $('.carousel').flickity({...}); 766 | ``` 767 | 768 | {{! ----------------------------------------------------------------- }} 769 | 770 |

Properties

771 | 772 |
773 |

Properties are accessed only on Flickity instances. If you initialized Flickity with jQuery, use .data('flickity') to get the instance.

774 | 775 | ``` js 776 | // init Flickity with jQuery 777 | var $carousel = $('.carousel').flickity(); 778 | // get instance 779 | var flkty = $carousel.data('flickity'); 780 | // access properties 781 | console.log( flkty.selectedIndex, flkty.selectedElement ); 782 | ``` 783 |
784 | 785 |

selectedIndex

786 | 787 |

Zero-based index of the selected slide.

788 | 789 | ``` js 790 | flkty.selectedIndex 791 | ``` 792 | 793 | {{! ----------------------------------------------------------------- }} 794 | 795 |

selectedElement

796 | 797 |

The selected cell element. For groupCells, the first cell element in the selected slide.

798 | 799 | ``` js 800 | flkty.selectedElement 801 | ``` 802 | 803 | {{! ----------------------------------------------------------------- }} 804 | 805 |

selectedElements

806 | 807 |

An array of elements in the selected slide. Useful for groupCells.

808 | 809 | ``` js 810 | flkty.selectedElements 811 | // -> array of elements 812 | ``` 813 | 814 | {{! ----------------------------------------------------------------- }} 815 | 816 |

cells

817 | 818 |

The array of cells. Use cells.length for the total number of cells.

819 | 820 | ``` js 821 | flkty.cells 822 | // -> array of cells 823 | flkty.cells.length 824 | // -> total number of cells 825 | ``` 826 | 827 | {{! ----------------------------------------------------------------- }} 828 | 829 |

slides

830 | 831 |

The array of slides. Useful for groupCells. A slide contains multiple cells. If groupCells is disabled, then each slide is a cell, so they are one in the same.

832 | 833 | ``` js 834 | flkty.slides 835 | // -> array of slides 836 | flkty.slides.length 837 | // -> total number of slides 838 | ``` 839 | -------------------------------------------------------------------------------- /content/events.hbs: -------------------------------------------------------------------------------- 1 | --- 2 | title: Events 3 | --- 4 | 5 | {{! ----------------------------------------------------------------- }} 6 | 7 |

Event binding

8 | 9 | {{! ----------------------------------------------------------------- }} 10 | 11 |

jQuery event binding

12 | 13 |

Bind events with jQuery with standard jQuery event methods .on(), .off(), and .one(). Event names are namespaced with .flickity.

14 | 15 | ``` js 16 | // jQuery 17 | function listener(/* parameters */) { 18 | console.log('eventName happened'); 19 | } 20 | // bind event listener 21 | $carousel.on( 'eventName.flickity', listener ); 22 | // unbind event listener 23 | $carousel.off( 'eventName.flickity', listener ); 24 | // bind event listener to trigger once. note ONE not ON 25 | $carousel.one( 'eventName.flickity', function() { 26 | console.log('eventName happened just once'); 27 | }); 28 | ``` 29 | 30 | {{! ----------------------------------------------------------------- }} 31 | 32 |

Vanilla JS event binding

33 | 34 |

Bind events with vanilla JS with .on(), .off(), and .once() methods.

35 | 36 | ``` js 37 | // vanilla JS 38 | function listener(/* parameters */) { 39 | console.log('eventName happened'); 40 | } 41 | // bind event listener 42 | flkty.on( 'eventName', listener ); 43 | // unbind event listener 44 | flkty.off( 'eventName', listener ); 45 | // bind event listener to trigger once. note ONCE not ONE or ON 46 | flkty.once( 'eventName', function() { 47 | console.log('eventName happened just once'); 48 | }); 49 | ``` 50 | 51 | {{! ----------------------------------------------------------------- }} 52 | 53 |

on option

54 | 55 |

Bind events within Flickity's options by setting on to an Object. The object's keys should match the event names. on is useful for capturing events as Flickity is initialized, like ready

56 | 57 |
58 |
59 | ``` js 60 | // jQuery 61 | var $carousel = $('.carousel').flickity({ 62 | on: { 63 | ready: function() { 64 | console.log('Flickity is ready'); 65 | }, 66 | change: function( index ) { 67 | console.log( 'Slide changed to' + index ); 68 | } 69 | } 70 | }); 71 | ``` 72 |

When using on with jQuery, event listener functions will use their vanilla JS form, and not include the jQuery event argument.

73 |
74 |
75 | ``` js 76 | // vanilla JS 77 | var flkty = new Flickity( '.carousel', { 78 | on: { 79 | ready: function() { 80 | console.log('Flickity is ready'); 81 | }, 82 | change: function( index ) { 83 | console.log( 'Slide changed to' + index ); 84 | } 85 | } 86 | }); 87 | ``` 88 |
89 |
90 | 91 | 92 | 93 | {{! ----------------------------------------------------------------- }} 94 | 95 |

Events demo

96 | 97 |

Play around with this carousel to see how events are triggered.

98 | 99 | {{> events-table }} 100 | 101 | {{! ----------------------------------------------------------------- }} 102 | 103 |

Flickity events

104 | 105 | {{! ----------------------------------------------------------------- }} 106 | 107 |

ready

108 | 109 |

Triggered after Flickity has been activated.

110 | 111 |

With jQuery, bind event listener first, then initialize Flickity.

112 | 113 | ``` js 114 | // jQuery 115 | var $carousel = $('.carousel'); 116 | // bind event listener first 117 | $carousel.on( 'ready.flickity', function() { 118 | console.log('Flickity ready'); 119 | }); 120 | // initialize Flickity 121 | $carousel.flickity(); 122 | ``` 123 | {{> edit-demo default="NYROXK" }} 124 | 125 |

With vanilla JS, bind listener with the on option, as the ready event may be triggered immediately.

126 | 127 | ``` js 128 | // vanilla JS 129 | var flkty = new Flickity( '.carousel', { 130 | on: { 131 | ready: function() { 132 | console.log('Flickity ready'); 133 | } 134 | } 135 | }); 136 | ``` 137 | {{> edit-demo default="qoaJVp" }} 138 | 139 | {{! ----------------------------------------------------------------- }} 140 | 141 |

change

142 | 143 |

Triggered when the selected slide is changed.

144 | 145 | ``` js 146 | // jQuery 147 | $carousel.on( 'change.flickity', function( event, index ) { 148 | console.log( 'Slide changed to ' + index ) 149 | }); 150 | ``` 151 | ```js 152 | // vanilla JS 153 | flkty.on( 'change', function( index ) {...}); 154 | ``` 155 | 156 |

157 | index 158 | Number 159 | Zero-based number of the selected slide. 160 |

161 | 162 | {{> edit-demo default="bvwxyO" vanillaJS="ZxpMdY" }} 163 | 164 | {{! ----------------------------------------------------------------- }} 165 | 166 |

select

167 | 168 |

Triggered when a slide is selected.

169 | 170 |

select is triggered any time a slide is selected, even on the same slide. change is triggered only when a different slide is selected.

171 | 172 |

This event was previously cellSelect in Flickity v1. cellSelect will continue to work in Flickity v2.

173 | 174 | ``` js 175 | // jQuery 176 | $carousel.on( 'select.flickity', function( event, index ) { 177 | console.log( 'Flickity select ' + index ) 178 | }); 179 | ``` 180 | ```js 181 | // vanilla JS 182 | flkty.on( 'select', function( index ) {...}); 183 | ``` 184 | 185 |

186 | index 187 | Number 188 | Zero-based number of the selected slide. 189 |

190 | 191 | {{> edit-demo default="emVgqE" vanillaJS="ogEwXe" }} 192 | 193 | {{! ----------------------------------------------------------------- }} 194 | 195 |

settle

196 | 197 |

Triggered when the slider is settled at its end position.

198 | 199 | ``` js 200 | // jQuery 201 | $carousel.on( 'settle.flickity', function( event, index ) { 202 | console.log( 'Flickity settled at ' + index ); 203 | }); 204 | ``` 205 | ```js 206 | // vanilla JS 207 | flkty.on( 'settle', function( index ) {...}); 208 | ``` 209 | 210 |

211 | index 212 | Number 213 | Zero-based number of the selected slide. 214 |

215 | 216 | {{> edit-demo default="yyvXYL" vanillaJS="myXweK" }} 217 | 218 | {{! ----------------------------------------------------------------- }} 219 | 220 |

scroll

221 | 222 |

Triggered when the slider moves.

223 | 224 | ``` js 225 | // jQuery 226 | $carousel.on( 'scroll.flickity', function( event, progress ) { 227 | console.log( 'Flickity scrolled ' + progress * 100 + '%' ) 228 | }); 229 | ``` 230 | ```js 231 | // vanilla JS 232 | flkty.on( 'scroll', function( progress ) {...}); 233 | ``` 234 | 235 |

236 | progress 237 | Number 238 | How far slider has moved, from 0 at the first slide to 1 at the end 239 |

240 | 241 |
242 |
243 | ``` js 244 | $carousel.on( 'scroll.flickity', function( event, progress ) { 245 | progress = Math.max( 0, Math.min( 1, progress ) ); 246 | $progressBar.width( progress * 100 + '%' ); 247 | }); 248 | ``` 249 |
250 | {{> progress-bar}} 251 |
252 | 253 |

Use scroll to create parallax effects.

254 | 255 |
256 |
257 | ``` js 258 | var flkty = $carousel.data('flickity'); 259 | var $imgs = $('.carousel-cell img'); 260 | 261 | $carousel.on( 'scroll.flickity', function( event, progress ) { 262 | flkty.slides.forEach( function( slide, i ) { 263 | var img = $imgs[i]; 264 | var x = ( slide.target + flkty.x ) * -1/3; 265 | img.style.transform = 'translateX( ' + x + 'px)'; 266 | }); 267 | }); 268 | ``` 269 |
270 | {{> keyhole }} 271 |
272 | 273 |
274 |
275 | ``` js 276 | var cellRatio = 0.6; // outerWidth of cell / width of carousel 277 | var bgRatio = 0.8; // width of background layer / width of carousel 278 | var fgRatio = 1.25; // width of foreground layer / width of carousel 279 | 280 | $carousel.on( 'scroll.flickity', function( event, progress ) { 281 | moveParallaxLayer( $background, bgRatio, progress ); 282 | moveParallaxLayer( $foreground, fgRatio, progress ); 283 | }); 284 | // trigger initial scroll 285 | $carousel.flickity('reposition'); 286 | 287 | var flkty = $carousel.data('flickity'); 288 | var count = flkty.slides.length - 1; 289 | 290 | function moveParallaxLayer( $layer, layerRatio, progress ) { 291 | var ratio = cellRatio * layerRatio; 292 | $layer.css({ 293 | left: ( 0.5 - ( 0.5 + progress * count ) * ratio ) * 100 + '%' 294 | }); 295 | } 296 | ``` 297 |
298 |
299 | {{> parallax }} 300 |
301 |
302 | 303 | {{! ----------------------------------------------------------------- }} 304 | 305 |

dragStart

306 | 307 |

Triggered when dragging starts and the slider starts moving.

308 | 309 | ``` js 310 | // jQuery 311 | $carousel.on( 'dragStart.flickity', function( event, pointer ) {...}); 312 | ``` 313 | ```js 314 | // vanilla JS 315 | flkty.on( 'dragStart', function( event, pointer ) {...}); 316 | ``` 317 | 318 |

319 | event 320 | Event 321 | Original event object, like mousedown, touchstart, or pointerdown. 322 |

323 |

324 | pointer 325 | Event or Touch 326 | The event object that has .pageX and .pageY. 327 |

328 | 329 | {{> edit-demo default="KwQqWw" vanillaJS="RNQgpB" }} 330 | 331 | {{! ----------------------------------------------------------------- }} 332 | 333 |

dragMove

334 | 335 |

Triggered when dragging moves and the slider moves.

336 | 337 | ``` js 338 | // jQuery 339 | $carousel.on( 'dragMove.flickity', function( event, pointer, moveVector ) {...}); 340 | ``` 341 | ```js 342 | // vanilla JS 343 | flkty.on( 'dragMove', function( event, pointer, moveVector ) {...}); 344 | ``` 345 | 346 |

347 | event 348 | Event 349 | Original event object, like mousemove, touchmove, or pointermove. 350 |

351 |

352 | pointer 353 | Event or Touch 354 | The event object that has .pageX and .pageY. 355 |

356 |

357 | moveVector 358 | Object 359 | How far the pointer has moved from its start position { x: 20, y: -30 }. 360 |

361 | 362 | {{> edit-demo default="azqwWW" vanillaJS="YPeQVL" }} 363 | 364 | {{! ----------------------------------------------------------------- }} 365 | 366 |

dragEnd

367 | 368 |

Triggered when dragging ends.

369 | 370 | ``` js 371 | // jQuery 372 | $carousel.on( 'dragEnd.flickity', function( event, pointer ) {...}); 373 | ``` 374 | ```js 375 | // vanilla JS 376 | flkty.on( 'dragEnd', function( event, pointer ) {...}); 377 | ``` 378 | 379 |

380 | event 381 | Event 382 | Original event object, like mouseup, touchend, or pointerup. 383 |

384 |

385 | pointer 386 | Event or Touch 387 | The event object that has .pageX and .pageY. 388 |

389 | 390 | {{> edit-demo default="ByYZRb" vanillaJS="jEZwwO" }} 391 | 392 | {{! ----------------------------------------------------------------- }} 393 | 394 |

pointerDown

395 | 396 |

Triggered when the user's pointer (mouse, touch, pointer) presses down.

397 | 398 | ``` js 399 | // jQuery 400 | $carousel.on( 'pointerDown.flickity', function( event, pointer ) {...}); 401 | ``` 402 | ```js 403 | // vanilla JS 404 | flkty.on( 'pointerDown', function( event, pointer ) {...}); 405 | ``` 406 | 407 |

408 | event 409 | Event 410 | Original event object, like mousedown, touchstart, or pointerdown. 411 |

412 |

413 | pointer 414 | Event or Touch 415 | The event object that has .pageX and .pageY. 416 |

417 | 418 | {{> edit-demo default="zxRzzZ" vanillaJS="ByYZZE" }} 419 | 420 | {{! ----------------------------------------------------------------- }} 421 | 422 |

pointerMove

423 | 424 |

Triggered when the user's pointer moves.

425 | 426 | ``` js 427 | // jQuery 428 | $carousel.on( 'pointerMove.flickity', function( event, pointer, moveVector ) {...}); 429 | ``` 430 | ```js 431 | // vanilla JS 432 | flkty.on( 'pointerMove', function( event, pointer, moveVector ) {...}); 433 | ``` 434 | 435 |

436 | event 437 | Event 438 | Original event object, like mousemove, touchmove, or pointermove. 439 |

440 |

441 | pointer 442 | Event or Touch 443 | The event object that has .pageX and .pageY. 444 |

445 |

446 | moveVector 447 | Object 448 | How far the pointer has moved from its start position { x: 20, y: -30 }. 449 |

450 | 451 | {{> edit-demo default="XJZgap" vanillaJS="JoLZMP" }} 452 | 453 | {{! ----------------------------------------------------------------- }} 454 | 455 |

pointerUp

456 | 457 |

Triggered when the user's pointer unpresses.

458 | 459 | ``` js 460 | // jQuery 461 | $carousel.on( 'pointerUp.flickity', function( event, pointer ) {...}); 462 | ``` 463 | ```js 464 | // vanilla JS 465 | flkty.on( 'pointerUp', function( event, pointer ) {...}); 466 | ``` 467 | 468 |

469 | event 470 | Event 471 | Original event object, like mouseup, touchend, or pointerup. 472 |

473 |

474 | pointer 475 | Event or Touch 476 | The event object that has .pageX and .pageY. 477 |

478 | 479 | {{> edit-demo default="qExjXV" vanillaJS="pvawrj" }} 480 | 481 | {{! ----------------------------------------------------------------- }} 482 | 483 |

staticClick

484 | 485 |

Triggered when the user's pointer is pressed and unpressed and has not moved enough to start dragging.

486 | 487 |

click events are hard to detect with draggable UI, as they are triggered whenever a user drags. Flickity's staticClick event resolves this, as it is triggered when the user has not dragged.

488 | 489 | ``` js 490 | // jQuery 491 | $carousel.on( 'staticClick.flickity', function( event, pointer, cellElement, cellIndex ) {...}); 492 | ``` 493 | ```js 494 | // vanilla JS 495 | flkty.on( 'staticClick', function( event, pointer, cellElement, cellIndex ) {...}); 496 | ``` 497 | 498 |

499 | event 500 | Event 501 | Original event object. 502 |

503 |

504 | pointer 505 | Event or Touch 506 | The event object that has .pageX and .pageY. 507 |

508 |

509 | cellElement 510 | Element 511 | If a cell was clicked, the element. 512 |

513 |

514 | cellIndex 515 | Integer 516 | If a cell was clicked, the cell’s zero-based number. 517 |

518 | 519 |

Use the cellElement and cellIndex parameters to detect what cell was clicked.

520 | 521 |
522 |
523 | ``` js 524 | $carousel.on( 'staticClick.flickity', function( event, pointer, cellElement, cellIndex ) { 525 | // dismiss if cell was not clicked 526 | if ( !cellElement ) { 527 | return; 528 | } 529 | // change cell background with .is-clicked 530 | $carousel.find('.is-clicked').removeClass('is-clicked'); 531 | $( cellElement ).addClass('is-clicked'); 532 | $logger.text( 'Cell ' + ( cellIndex + 1 ) + ' clicked' ); 533 | }); 534 | ``` 535 |
536 | {{> static-click }} 537 |
538 | 539 | {{! ----------------------------------------------------------------- }} 540 | 541 |

lazyLoad

542 | 543 |

Triggered after an image has been loaded with lazyLoad.

544 | 545 | ``` js 546 | // jQuery 547 | $carousel.on( 'lazyLoad.flickity', function( event, cellElement ) {...}); 548 | ``` 549 | ```js 550 | // vanilla JS 551 | flkty.on( 'lazyLoad', function( event, cellElement ) {...}); 552 | ``` 553 | 554 |

555 | event 556 | Event 557 | Original event object. 558 |

559 |

560 | cellElement 561 | Element 562 | The image's cell element. 563 |

564 | 565 |

lazyLoad is triggered on both valid images and broken images. Check event.type to see if the loaded image was loaded with load or error. Use event.target to access the loaded image.

566 | 567 | ``` js 568 | // jQuery 569 | $carousel.on( 'lazyLoad.flickity', function( event, cellElement ) { 570 | var img = event.originalEvent.target; 571 | console.log( event.originalEvent.type, img.src ); 572 | // load or error on src 573 | }); 574 | ``` 575 | ```js 576 | // vanilla JS 577 | flkty.on( 'lazyLoad', function( event, cellElement ) { 578 | var img = event.target; 579 | console.log( event.type, img.src ); 580 | }); 581 | ``` 582 | 583 | {{> edit-demo default="RPqMra" vanillaJS="VLVXjv" }} 584 | 585 | {{! ----------------------------------------------------------------- }} 586 | 587 |

bgLazyLoad

588 | 589 |

Triggered after a background image has been loaded with bgLazyLoad.

590 | 591 | ``` js 592 | // jQuery 593 | $carousel.on( 'bgLazyLoad.flickity', function( event, element ) {...}); 594 | ``` 595 | ```js 596 | // vanilla JS 597 | flkty.on( 'bgLazyLoad', function( event, element ) {...}); 598 | ``` 599 | 600 |

601 | event 602 | Event 603 | Original event object. 604 |

605 |

606 | element 607 | Element 608 | The element of the background image. 609 |

610 | 611 | {{! ----------------------------------------------------------------- }} 612 | 613 |

fullscreenChange

614 | 615 |

Triggered after entering or exiting fullscreen view.

616 | 617 | 618 | ``` js 619 | // jQuery 620 | $carousel.on( 'fullscreenChange.flickity', function( event, isFullscreen ) {...}); 621 | ``` 622 | ```js 623 | // vanilla JS 624 | flkty.on( 'fullscreenChange', function( isFullscreen ) {...}); 625 | ``` 626 | 627 |

628 | isFullscreen 629 | Boolean 630 | true if viewing fullscreen, false if exiting fullscreen 631 |

632 | -------------------------------------------------------------------------------- /content/extras.hbs: -------------------------------------------------------------------------------- 1 | --- 2 | title: Extras 3 | --- 4 | 5 | {{! ----------------------------------------------------------------- }} 6 | 7 |

Extra demos

8 | 9 | 41 | 42 | {{! ----------------------------------------------------------------- }} 43 | 44 |

Custom navigation UI

45 | 46 |

With the Flickity API, you can build custom carousel navigation UI.

47 | 48 |
49 |
50 | ``` js 51 | // init Flickity 52 | var $carousel = $('.carousel').flickity({ 53 | prevNextButtons: false, 54 | pageDots: false 55 | }); 56 | // Flickity instance 57 | var flkty = $carousel.data('flickity'); 58 | // elements 59 | var $cellButtonGroup = $('.button-group--cells'); 60 | var $cellButtons = $cellButtonGroup.find('.button'); 61 | 62 | // update selected cellButtons 63 | $carousel.on( 'select.flickity', function() { 64 | $cellButtons.filter('.is-selected') 65 | .removeClass('is-selected'); 66 | $cellButtons.eq( flkty.selectedIndex ) 67 | .addClass('is-selected'); 68 | }); 69 | 70 | // select cell on button click 71 | $cellButtonGroup.on( 'click', '.button', function() { 72 | var index = $(this).index(); 73 | $carousel.flickity( 'select', index ); 74 | }); 75 | // previous 76 | $('.button--previous').on( 'click', function() { 77 | $carousel.flickity('previous'); 78 | }); 79 | // next 80 | $('.button--next').on( 'click', function() { 81 | $carousel.flickity('next'); 82 | }); 83 | ``` 84 |
85 | {{> custom-nav }} 86 |
87 | 88 | {{! ----------------------------------------------------------------- }} 89 | 90 |

Module loaders

91 | 92 | {{! ----------------------------------------------------------------- }} 93 | 94 |

Webpack

95 | 96 |

Install Flickity with npm.

97 | 98 | ``` bash 99 | npm install flickity 100 | ``` 101 | 102 |

You can then require('flickity').

103 | 104 | ``` js 105 | // main.js 106 | var Flickity = require('flickity'); 107 | 108 | var flkty = new Flickity( '.carousel', { 109 | // options... 110 | }); 111 | ``` 112 | 113 |

Run webpack.

114 | 115 | ``` bash 116 | webpack main.js bundle.js 117 | ``` 118 | 119 |

Install and require add-on features for imagesLoaded, asNavFor, fullscreen, bgLazyLoad, and hash.

120 | 121 | ``` bash 122 | npm install flickity-imagesloaded 123 | npm install flickity-fullscreen 124 | ``` 125 | 126 | ``` js 127 | var Flickity = require('flickity'); 128 | require('flickity-imagesloaded'); 129 | require('flickity-fullscreen'); 130 | 131 | // now use imagesLoaded and fullscreen 132 | var flkty = new Flickity( '.carousel', { 133 | imagesLoaded: true, 134 | fullscreen: true, 135 | }); 136 | ``` 137 | 138 |

To use Flickity as a jQuery plugin with Webpack, you need to call jQuery Bridget and Flickity.setJQuery().

139 | 140 | ``` bash 141 | npm install jquery-bridget 142 | ``` 143 | 144 | ``` js 145 | var $ = require('jquery'); 146 | var jQueryBridget = require('jquery-bridget'); 147 | var Flickity = require('flickity'); 148 | 149 | // make Flickity a jQuery plugin 150 | Flickity.setJQuery( $ ); 151 | jQueryBridget( 'flickity', Flickity, $ ); 152 | // now you can use $().flickity() 153 | var $carousel = $('.carousel').flickity({...}); 154 | ``` 155 | 156 | {{! ----------------------------------------------------------------- }} 157 | 158 |

Browserify

159 | 160 |

Follow Webpack instructions. Then run browserify.

161 | 162 | ``` bash 163 | browserify main.js -o bundle.js 164 | ``` 165 | 166 | {{! ----------------------------------------------------------------- }} 167 | 168 |

RequireJS

169 | 170 |

Flickity supports RequireJS.

171 | 172 |

You can require flickity.pkgd.js.

173 | 174 | ``` js 175 | requirejs( [ 176 | 'path/to/flickity.pkgd.js', 177 | ], function( Flickity ) { 178 | var flkty = new Flickity( '.carousel', {...}); 179 | }); 180 | ``` 181 | 182 |

Install and require add-on features for imagesLoaded, asNavFor, fullscreen, bgLazyLoad, and hash.

183 | 184 | ``` js 185 | requirejs( [ 186 | 'path/to/flickity.pkgd.js', 187 | 'path/to/flickity-imagesloaded/flickity-imagesloaded.js', 188 | 'path/to/flickity-fullscreen/fullscreen.js', 189 | ], function( Flickity ) { 190 | var flkty = new Flickity( '.carousel', { 191 | imagesLoaded: true, 192 | fullscreen: true, 193 | }); 194 | }); 195 | ``` 196 | 197 |

To use Flickity as a jQuery plugin with RequireJS and flickity.pkgd.js, you need to call jQuery Bridget.

198 | 199 | ``` js 200 | // require the require function 201 | requirejs( [ 'require', 'jquery', 'path/to/flickity.pkgd.js' ], 202 | function( require, $, Flickity ) { 203 | // require jquery-bridget, it's included in flickity.pkgd.js 204 | require( [ 'jquery-bridget/jquery-bridget' ], 205 | function( jQueryBridget ) { 206 | // make Flickity a jQuery plugin 207 | jQueryBridget( 'flickity', Flickity, $ ); 208 | // now you can use $().flickity() 209 | var $carousel = $('.carousel').flickity({...}); 210 | } 211 | ); 212 | }); 213 | ``` 214 | 215 |

Or, you can manage dependencies with npm or Bower. Set baseUrl to the packages folder and set a config path for all your application code.

216 | 217 | ``` js 218 | requirejs.config({ 219 | baseUrl: 'node_modules/', 220 | paths: { 221 | app: '../' 222 | } 223 | }); 224 | 225 | requirejs( [ 226 | 'flickity/js/index', 227 | 'app/my-component.js' 228 | ], function( Flickity, myComp ) { 229 | var flkty = new Flickity( '.carousel', {...}); 230 | }); 231 | ``` 232 | 233 |

To use Flickity as a jQuery plugin with RequireJS and a package manager, you need to install and call jQuery Bridget.

234 | 235 | ``` js 236 | requirejs.config({ 237 | baseUrl: 'node_modules/', 238 | paths: { 239 | jquery: 'jquery/jquery' 240 | } 241 | }); 242 | 243 | requirejs( [ 244 | 'jquery', 245 | 'flickity/js/index', 246 | 'jquery-bridget/jquery-bridget' 247 | ], 248 | function( $, Flickity ) { 249 | // make Flickity a jQuery plugin 250 | $.bridget( 'flickity', Flickity, $ ); 251 | // now you can use $().flickity() 252 | var $carousel = $('.carousel').flickity({...}); 253 | }); 254 | ``` 255 | 256 | {{! ----------------------------------------------------------------- }} 257 | 258 |

Browser support

259 | 260 |

Flickity v2.1 supports Chrome 33+, Safari 9+ (mobile & desktop), IE11+, Edge 12+, and Firefox 23+.

261 | 262 |

For IE8+ and Android 2.3+ support, try Flickity v1.

263 | 264 | {{! ----------------------------------------------------------------- }} 265 | 266 |

Upgrading from v1

267 | 268 |

Flickity v2 dropped browser support for IE8, IE9, and Android 2.3. Nearly all options, methods, and code for Flickity v1 is backwards compatibile with Flickity v2.

269 | 270 |

Breaking changes

271 | 272 | 284 | 285 |

Compatible changes

286 | 287 | 292 | 293 |

New features

294 | 295 | 302 | 303 | {{! ----------------------------------------------------------------- }} 304 | 305 |

Issues

306 | 307 |

Reduced test cases

308 | 309 |

Creating a reduced test case is the best way to debug problems and report issues. Read CSS Tricks on why they’re so great.

310 | 311 |

Create a reduced test case for Flickity by forking any one of the CodePen demos from these docs.

312 | 313 | 318 | 319 |

Creating a reduced test case is the best way to get your issue addressed. They help you point out the problem. They help us debug the problem. They help others understand the problem.

320 | 321 | {{! ----------------------------------------------------------------- }} 322 | 323 |

Submitting issues

324 | 325 |

Report issues on GitHub. Make sure to include a reduced test case. Without a reduced test case, your issue may be closed.

326 | 327 | {{! ----------------------------------------------------------------- }} 328 | 329 |

Feature requests

330 | 331 |

Help us select new features by looking over requested features on the GitHub issue tracker and adding your 👍 reaction to features you’d like to see added.

332 | 333 | {{! ----------------------------------------------------------------- }} 334 | -------------------------------------------------------------------------------- /content/index.hbs: -------------------------------------------------------------------------------- 1 | --- 2 | is_homepage: true 3 | --- 4 | 5 | {{! ----------------------------------------------------------------- }} 6 | 7 |

Install

8 | 9 | {{! ----------------------------------------------------------------- }} 10 | 11 |

Download

12 | 13 | 29 | 30 | {{! ----------------------------------------------------------------- }} 31 | 32 |

CDN

33 | 34 |

Link directly to Flickity files on unpkg.

35 | 36 | ``` html 37 | 38 | 39 | ``` 40 | 41 | ``` html 42 | 43 | 44 | ``` 45 | 46 | {{! ----------------------------------------------------------------- }} 47 | 48 |

Package managers

49 | 50 |

Install with npm: npm install flickity

51 | 52 |

Install with Bower: bower install flickity --save

53 | 54 | {{! ----------------------------------------------------------------- }} 55 | 56 |

License

57 | 58 | {{! ----------------------------------------------------------------- }} 59 | 60 |

Commercial license

61 | 62 |

If 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. Read more about Flickity commercial licensing.

63 | 64 |

Once purchased, you’ll receive a commercial license PDF and be all set to use Flickity in your commercial applications.

65 | 66 |
67 | {{#licenses.developer}} 68 | {{> buy-button}} 69 | {{/licenses.developer}} 70 | 71 | {{#licenses.team}} 72 | {{> buy-button}} 73 | {{/licenses.team}} 74 | 75 | {{#licenses.organization}} 76 | {{> buy-button}} 77 | {{/licenses.organization}} 78 |
79 | 80 | {{! ----------------------------------------------------------------- }} 81 | 82 |

Open source license

83 | 84 |

If you are creating an open source application under a license compatible with the GNU GPL license v3, you may use Flickity under the terms of the GPLv3. Read more about Flickity open source licensing.

85 | 86 | {{! ----------------------------------------------------------------- }} 87 | 88 |

Getting started

89 | 90 |

Include the Flickity .css and .js files in your site.

91 | 92 | ``` html 93 | 94 | ``` 95 | 96 | ``` html 97 | 98 | ``` 99 | 100 |

Flickity works on a container carousel element with a group of cell elements.

101 | 102 | ``` html 103 | 109 | ``` 110 | 111 |

There are several ways to initialize Flickity.

112 | 113 | {{! ----------------------------------------------------------------- }} 114 | 115 |

Initialize with jQuery

116 | 117 |

You can use Flickity as a jQuery plugin: $('selector').flickity().

118 | 119 | ``` js 120 | $('.main-carousel').flickity({ 121 | // options 122 | cellAlign: 'left', 123 | contain: true 124 | }); 125 | ``` 126 | 127 | {{! ----------------------------------------------------------------- }} 128 | 129 |

Initialize with vanilla JavaScript

130 | 131 |

You can use Flickity with vanilla JS: new Flickity( elem ). The Flickity() constructor accepts two arguments: the carousel element and an options object.

132 | 133 | ``` js 134 | var elem = document.querySelector('.main-carousel'); 135 | var flkty = new Flickity( elem, { 136 | // options 137 | cellAlign: 'left', 138 | contain: true 139 | }); 140 | 141 | // element argument can be a selector string 142 | // for an individual element 143 | var flkty = new Flickity( '.main-carousel', { 144 | // options 145 | }); 146 | ``` 147 | 148 | {{! ----------------------------------------------------------------- }} 149 | 150 |

Initialize with HTML

151 | 152 |

You can initialize Flickity in HTML, without writing any JavaScript. Add data-flickity attribute to the carousel element. Options can be set in its value.

153 | 154 | 155 | ``` html 156 |