Giter Club home page Giter Club logo

flexisel's Introduction

Flexisel

A responsive carousel jQuery plugin...

View Demo | Buy Author a Coffee

All you have to do is call flexisel on your unordered list containing images. Call it on the $(window).load event (as opposed to the $(document).ready event) so that Flexisel can calculate the width of the images and figure out how to space them out properly. For example...

$(window).load(function() {
  $("#myCarousel").flexisel();
});

Below is how you'd call it passing in all the options....

$(window).load(function() {
  $("#myCarousel").flexisel({
    visibleItems: 4,
    itemsToScroll: 3,
    animationSpeed: 400,
    infinite: true,
    navigationTargetSelector: null,
    autoPlay: {
      enable: false,
      interval: 5000,
      pauseOnHover: true
    },
    responsiveBreakpoints: { 
      portrait: { 
        changePoint:480,
        visibleItems: 1,
        itemsToScroll: 1
      }, 
        landscape: { 
        changePoint:640,
        visibleItems: 2,
        itemsToScroll: 2
      },
        tablet: { 
        changePoint:768,
        visibleItems: 3,
        itemsToScroll: 3
      }
    }
  });
});

Options

Below is a listing of some basic options you can set...

Option Value Default Value Description Example
visibleItems Integer 4 Sets the initial number of visible items in the carousel visibleItems: 5
itemsToScroll Integer 3 Sets the initial number of items that you want to scroll. Note: This value will be overridden by responsive breakpoint settings at smaller or larger screen widths itemsToScroll: 2
animationSpeed Integer (in Milliseconds) 400 Sets the "speed" of the animation when the carousel navigates right or left. animationSpeed: 1000
infinite Boolean true Sets whether or not the carousel wraps infinitely infinite: false
navigationTargetSelector String (selector) null The left/right arrows will be added to the element with this selector instead of the default navigationTargetSelector: '#navigation'
autoPlay Object autoPlay: { enable: false, interval: 5000, pauseOnHover: true } Values for setting autoplay. The "enable" property must be true for this to apply autoPlay: { enable: true, interval: 7000, pauseOnHover: false }
loaded function function(object) { } Callback function that runs after the slider is loaded and initialized. A jQuery reference to the instance of the carousel is passed in as the first argument. loaded: function(object) { console.log('Slider loaded...'); }
before function function(object) { } Callback function that runs before a slide transition. A jQuery reference to the instance of the carousel is passed in as the first argument. before: function(object) { console.log('Before transition...'); }
after function function(object) { } Callback function that runs after a slide transition. A jQuery reference to the instance of the carousel is passed in as the first argument. after: function(object) { console.log('After transition...'); }
resize function function(object) { } Callback function that runs after a throttled resize event finishes. A jQuery reference to the instance of the carousel is passed in as the first argument. resize: function(object) { console.log('After resize...'); }

Responsive Breakpoints

This is an object that specifies responsive breakpoints. You can name your objects whatever you want (the default names provided are "portrait," "landscape," and "tablet") and you can have as many or as few as you want (so you could add to or delete any of the defaults), but each one needs to have a "changePoint" a "visibleItems", and an "itemsToScroll" property. Those properties are required. The responsiveBreakpoints object sets the threshold of where the screen width falls below a certain width. So for example, the example default portrait responsive breakpoint will be applied to the carousel when the screen width is less than the changePoint value set for portrait. The number of items shown in this state will be whatever value is set for visibleItems and the number of items that scroll per click (or swipe) is set by the itemsToScroll property.

For example...

responsiveBreakpoints: { 
  portrait: { 
    changePoint:480,
    visibleItems: 1,
    itemsToScroll: 1
  }, 
  landscape: { 
    changePoint:640,
    visibleItems: 2,
    itemsToScroll: 2
  },
  tablet: { 
    changePoint:768,
    visibleItems: 3,
    itemsToScroll: 3
  }
}

The landscape responsive breakpoint will be applied when the screen width is greater than the width of the portrait changePoint value, but less that the width of the tablet changePoint value. Likewise, when the screen width falls below the tablet changePoint, the number of visibleItems set for the tablet event will be shown. The same is true for the portrait breakpoint. Usually, because the portrait responsive event is used to show portrait views on mobile phones, 1 is a good value to set for both visibleItems and itemsToScroll here. And remember you can pass as many or as few of these as you like in and you can name them whatever you want. So, for example, if you wanted to just have things only show 1 item on all views below a certain width you could pass in something like the following...

 responsiveBreakpoints: {
    mobile: {
      changePoint:768,
      visibleItems: 1,
      itemsToScroll: 1
    }
}

And then this will be the only point at which Flexisel changes.

View Demo | Buy Author a Coffee

flexisel's People

Contributors

9bitstudios avatar johnboyle05 avatar numanwd avatar tonichaz avatar x09326 avatar yeosblue avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.