:leaves: Touch, responsive, flickable carousels

Related tags

Sliders flickity
Overview

Flickity

Touch, responsive, flickable carousels

See flickity.metafizzy.co for complete docs and demos.

Install

Download

CDN

Link directly to Flickity files on unpkg.

<link rel="stylesheet" href="https://unpkg.com/flickity@2/dist/flickity.min.css">
<script src="https://unpkg.com/flickity@2/dist/flickity.pkgd.min.js"></script>

Package managers

Bower: bower install flickity --save

npm: npm install flickity --save

License

Commercial license

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. Purchase a Flickity Commercial License at flickity.metafizzy.co

Open source license

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's license.

Usage

Flickity works with a container element and a set of child cell elements

<div class="carousel">
  <div class="carousel-cell">...</div>
  <div class="carousel-cell">...</div>
  <div class="carousel-cell">...</div>
  ...
</div>

Options

var flky = new Flickity( '.gallery', {
  // options, defaults listed

  accessibility: true,
  // enable keyboard navigation, pressing left & right keys

  adaptiveHeight: false,
  // set carousel height to the selected slide

  autoPlay: false,
  // advances to the next cell
  // if true, default is 3 seconds
  // or set time between advances in milliseconds
  // i.e. `autoPlay: 1000` will advance every 1 second

  cellAlign: 'center',
  // alignment of cells, 'center', 'left', or 'right'
  // or a decimal 0-1, 0 is beginning (left) of container, 1 is end (right)

  cellSelector: undefined,
  // specify selector for cell elements

  contain: false,
  // will contain cells to container
  // so no excess scroll at beginning or end
  // has no effect if wrapAround is enabled

  draggable: '>1',
  // enables dragging & flicking
  // if at least 2 cells

  dragThreshold: 3,
  // number of pixels a user must scroll horizontally to start dragging
  // increase to allow more room for vertical scroll for touch devices

  freeScroll: false,
  // enables content to be freely scrolled and flicked
  // without aligning cells

  friction: 0.2,
  // smaller number = easier to flick farther

  groupCells: false,
  // group cells together in slides

  initialIndex: 0,
  // zero-based index of the initial selected cell

  lazyLoad: true,
  // enable lazy-loading images
  // set img data-flickity-lazyload="src.jpg"
  // set to number to load images adjacent cells

  percentPosition: true,
  // sets positioning in percent values, rather than pixels
  // Enable if items have percent widths
  // Disable if items have pixel widths, like images

  prevNextButtons: true,
  // creates and enables buttons to click to previous & next cells

  pageDots: true,
  // create and enable page dots

  resize: true,
  // listens to window resize events to adjust size & positions

  rightToLeft: false,
  // enables right-to-left layout

  setGallerySize: true,
  // sets the height of gallery
  // disable if gallery already has height set with CSS

  watchCSS: false,
  // watches the content of :after of the element
  // activates if #element:after { content: 'flickity' }

  wrapAround: false
  // at end of cells, wraps-around to first for infinite scrolling

});

By Metafizzy ๐ŸŒˆ ๐Ÿป

Comments
  • Performance issues in iOS 12 and 13 (beta)

    Performance issues in iOS 12 and 13 (beta)

    C755325C-238C-4964-9675-97384C34C186

    Dear Desandro and Flickity contributors,

    I used Flickity in my web and mobile app for two years, itโ€™s very great, sure.

    Recently, my customers have complained about issues in my carousel, it is performing not well in low battery mode, animations are slower than normal, hard to scroll.

    In iOS 13 (beta), its hard to scroll in freescroll mode, and i can vertical scroll when dragging my carousel.

    In my app:

    https://vimeo.com/344452939

    bug 
    opened by vukhacbiet 79
  • Slide by group

    Slide by group

    Playing with this great slider, i realize that it doesn't scroll with group of slide. Eg : When i see three slide in the viewport i expect, when i click on the next button, to have the next three slide. Or we just have the capabilities to have the next slide, one by one. Is it in project ?

    Thanks !

    feature request 
    opened by myconcretelab 79
  • Full screen support

    Full screen support

    Good job on this library. Very well organised and easy to use.

    Many image galleries will implement a full screen image feature that can toggle an image to full screen. Is there a plan to implement something similar?

    feature request 
    opened by asafbrukarz 70
  • Fade transition?

    Fade transition?

    While it's obvious that flickity is meant to be based on a sliding transition, I was curious if there's any plans on implementing an optional Fade based transition/animation instead of the slide?

    I would love to replace my current hand-rolled image galleries/carousels with flickity in my projects both personal and commercial, but many of them use fading transitions instead of sliding. I'd be more than happy to pre-pay for a commercial license/donate/whatever if it helps that get implemented.

    feature request 
    opened by rawcreative 70
  • Separate gallery scrolling from vertical page scrolling on touch devices

    Separate gallery scrolling from vertical page scrolling on touch devices

    Kiwistian

    is there a way to block the window vertical scroll, on mobile, while the user is swiping the slide?

    I'm considering changing the touchVerticalScroll behavior so that user can either scroll horizontally in the gallery OR scroll vertically on the page, but not do both.

    +1 or subscribe to this issue If you'd like to see this feature added.

    feature request 
    opened by desandro 51
  • Lazy load images

    Lazy load images

    Cool plugin so far! Testing it now in a prototype for one of our clients.

    Lazy Load 'slides' would be a killer feature if you ask me. Also for performance. Are there any plans to implement this?

    Good luck in getting to the v1.0 release ! :)

    feature request 
    opened by gerardkd 51
  • wrapAround when content width smaller than container

    wrapAround when content width smaller than container

    If you set wrapAround: true and have small amount of items that don't fill container -- then it causing trouble. See this pin, try remove some items and scroll slider.

    I'm suggestion add condition to _getWrapShiftCells method that will check widths

      // cancel wrap-around if content smaller than container
      var lastCell = this.getLastCell();
      var contentWidth = this.slideableWidth - lastCell.size[ this.options.rightToLeft ? 'marginLeft' : 'marginRight' ];
      if ( contentWidth <= this.size.innerWidth ) {
        this.options.wrapAround = false;
      } else {
        this.options.wrapAround = true;
      }
    

    Look at it. Is it right way?

    feature request 
    opened by komunyako 43
  • Options to define prev/next buttons SVG

    Options to define prev/next buttons SVG

    Would be nice to have an option to define the prev/next button svg code. For example:

    var flkty = new Flickity( '.flickity', {
      svgViewBox: 'x1 y2 x2 y2',
      svgPath: 'svg path',
      svgTransformLeft: 'translate(x,y)',
      svgTransformRight: 'translate(x,y) rotate(x)'
    });
    
    PrevNextButton.prototype.createSVG = function() {
      svg.setAttribute( 'viewBox', this.parent.options.svgViewBox );
      path.setAttribute( 'd', this.parent.options.svgPath );
      var arrowTransform = this.isLeft ? this.parent.options.svgTransformLeft : this.parent.options.svgTransformRight;
    };
    
    feature request 
    opened by FabianGabor 36
  • Flickity Touch events in mobile Chrome break

    Flickity Touch events in mobile Chrome break

    Hi everyone,

    I figured out that flickity stopped swiping on mobile chrome (android) and also in the chrome dev tools mobile simulator. The arrow buttons and flickity in general still work, but no swiping is possible. Either nothing happens or weird things. Desktop Chrome, iOS and everything else is fine.

    Multiple older projects (that worked with the exact same settings ~weeks ago, no changes!) stopped working!

    This happens only when I use flickity via the npm package npm install flickity and import Flickity from 'flickity'.

    It doesn't happen when I directly include the flickity sources via