Presentation

The purpose of Slider Kit is to gather common slideshow-like jQuery functionalities (such as news sliders, photos galleries/sliders, carousels, tabs menus) into one lightweight and flexible plugin combined with ready-to-use CSS skins.

Features

  • Content slider with modular elements
  • Multiple navigation controls: buttons, mousewheel, image click, keyboard (beta)
  • Vertical/Horizontal navigation clip
  • Vertical/Horizontal panels slide
  • Auto scrolling /┬áCircular scrolling
  • Fading and sliding transitions effects
  • Easing on transitions
  • Slider Kit generates a minimum of inline CSS. The whole skin is CSS-made
  • Light weight: < 8 Ko (packed)

Demos

Compatibility

  • Internet Explorer 9: yes
  • Internet Explorer 8: yes
  • Internet Explorer 7: yes
  • Internet Explorer 6: yes
  • Firefox: yes (tested on v3.6.1 & v4)
  • Chrome: yes (tested on v9.0.597.107)
  • Safari: yes (tested on v5.0.2)
  • Opera: yes (tested on v11.01)

Documentation

As many jQuery plugins, Slider Kit is a subtle combination of HTML, CSS and jQuery. The jQuery itself won't do any design or CSS. So you'll need to work on a CSS skin to get the design you want.

But first, let's see some HTML.

HTML

HTML elements

Slider container

CSS class name: [cssprefix].

This is the main container. It must have defined width and height values in the CSS. Because all of its child tags are in absolute position.

Content panel

CSS class name: [cssprefix]-panel.

This is the sliding part. The content can be anything: images, text, news, etc.

Previous button

CSS class name: [cssprefix]-go-btn [cssprefix]-go-prev.

This button will slide to the previous item. It can be placed anywhere inside the main container.

Next button

CSS class name: [cssprefix]-go-btn [cssprefix]-go-next.

This button will slide to the next item. It can be placed anywhere inside the main container.

Caption/Text-box

CSS class name: [cssprefix]-panel-textbox.

It is mostly used over photos. It can be placed anywhere over the panel area.

Nav/Carousel

CSS class name: [cssprefix]-nav.

This block contains navigation thumbnails. Thumbnail content can be anything, text or image.

Nav previous button

CSS class name: [cssprefix]-nav-btn [cssprefix]-nav-prev.

This button will scroll the nav bar to the right. It must be placed in the nav container.

Nav next button

CSS class name: [cssprefix]-nav-btn [cssprefix]-nav-next.

This button will scroll the nav bar to the left. It must be placed in the nav container.

[cssprefix] default value is "sliderkit". You can replace it with your own value.

HTML code

Here is a representative HTML structure to be used with Slider Kit:

<!-- Main container -->
<div class="sliderkit">

    <!-- Nav container -->
    <div class="sliderkit-nav">
    
        <!-- Nav clip -->
        <div class="sliderkit-nav-clip">
            <ul>
                <li><a href="#" rel="nofollow" title="[link title]">~content</a></li>
                <li><a href="#" rel="nofollow" title="[link title]">~content</a></li>
                <li><a href="#" rel="nofollow" title="[link title]">~content</a></li>
                <li><a href="#" rel="nofollow" title="[link title]">~content</a></li>
            </ul>
        </div>
        
        <!-- Nav buttons -->
        <div class="sliderkit-nav-btn sliderkit-nav-prev"><a rel="nofollow" href="#" title="Previous line"><span>Previous</span></a></div>
        <div class="sliderkit-nav-btn sliderkit-nav-next"><a rel="nofollow" href="#" title="Next line"><span>Next</span></a></div>
    
    </div><!-- // end of Nav container -->
    
    <!-- Panels container -->
    <div class="sliderkit-panels">    
    
        <!-- Go buttons -->
        <div class="sliderkit-go-btn sliderkit-go-prev"><a rel="nofollow" href="#" title="Previous"><span>Previous</span></a></div>
        <div class="sliderkit-go-btn sliderkit-go-next"><a rel="nofollow" href="#" title="Next"><span>Next</span></a></div>

        <!-- Panel divs -->
        <div class="sliderkit-panel">
            ~content
        </div>
        <div class="sliderkit-panel">
            ~content
        </div>
        <div class="sliderkit-panel">
            ~content
        </div>
        
    </div><!-- // end of Panels container -->
    
</div><!-- // end of Main container -->
  • The HTML code is flexible: you can use just the carousel, or just the panels. Buttons and captions are optional.
  • The 'go' buttons (sliderkit-go-btn) can be placed anywhere in the main container.

CSS

Core styles

The Slider Kit core CSS file is sliderkit-core.css.

It is required to make the plugin work properly. Of course you can paste it in your own CSS file and adapt it if needed.

Skinning

In addition to the core CSS, you have to build a CSS skin to get the design you want.

To help you in this hero quest, I wrote several CSS skins examples (check the demos pages to see them in action).

The demos CSS file is sliderkit-demos.css. Feel free to explore this file and take what you need.

Compatibility

For the sake of cross-browser compatibility, I added 3 CSS files for Internet Explorers (mainly for opacity and transparency problems):

  • sliderkit-demos-ie6.css.
  • sliderkit-demos-ie7.css.
  • sliderkit-demos-ie8.css.

CSS advices

  • Width and height values have to be set for the main container.
  • Nav <li> tag margin/padding values must be set in pixels.

In the <head> section of the HTML page:

<!-- Widget styles -->
<link rel="stylesheet" type="text/css" href="../lib/css/sliderkit-core.css" media="screen, projection" />
<link rel="stylesheet" type="text/css" href="../lib/css/sliderkit-demos.css" media="screen, projection" />

<!-- Compatibility fix -->
<!--[if IE 6]>
    <link rel="stylesheet" type="text/css" href="../lib/css/sliderkit-demos-ie6.css" />
<![endif]-->

<!--[if IE 7]>
    <link rel="stylesheet" type="text/css" href="../lib/css/sliderkit-demos-ie7.css" />
<![endif]-->

<!--[if IE 8]>
    <link rel="stylesheet" type="text/css" href="../lib/css/sliderkit-demos-ie8.css" />
<![endif]-->

Javascript

The main javascript file is currently jquery.sliderkit.1.5.1.pack.js (packed).

You can optionnaly use add-ons:

In the <head> section of the HTML page:

<!-- jQuery library -->
<script type="text/javascript" src="../lib/js/jquery-1.3.min.js"></script>

<!-- Slider Kit -->
<script type="text/javascript" src="../lib/js/jquery.sliderkit.1.5.1.pack.js"></script>

<!-- Add-ons -->
<script type="text/javascript" src="../lib/js/jquery.easing.1.3.min.js"></script>
<script type="text/javascript" src="../lib/js/jquery.mousewheel.min.js"></script>

<!-- Slider Kit execution -->
<script type="text/javascript">
    jQuery(window).load(function(){
        
        jQuery(".anytagselector").sliderkit();

    });
</script>

You can define the parameters of the plugin:

<!-- Slider Kit execution -->
<script type="text/javascript">
    jQuery(window).load(function(){
        
        jQuery(".anytagselector").sliderkit({
            shownavitems:5,
            auto:false
        });

    });
</script>

Check the 'Options' section below.

Options

cssprefix

(string) default is "sliderkit". The prefix to use on every CSS class names.

start

(int) default is 0. Set the start position. First is 0.

auto

(boolean) default is true. Activate auto-scrolling.

autospeed

(int) default is 4000. Set the auto-scrolling speed (ms).

mousewheel

(boolean) default is false. Activate the mousewheel navigation.

keyboard

(boolean) default is false. Activate the keyboard navigation. Very basic for now (left/right arrows only).

panelclick

(boolean) default is false. Activate the 1-click navigation.

circular

(boolean) default is false. Activate the infinite nav scroll.

shownavitems

(int) default is 5. Defines how many thumbnails to display in the nav clip.

navitemshover

(boolean) default is false. If set the panels will slide on nav thumbnails mouseover (by default panels slide on click).

navclipcenter

(boolean) default is false. Defines if the nav clip must be center-aligned in the nav container.

navcontinuous (v1.3)

(boolean) default is false. If set to true, will make the carousel scroll continuously (use this option with a "linear" scrolleasing).

navscrollatend (v1.5)

(boolean) default is false. If set to 'true', will make the carousel scroll if a line first or last thumbnail is clicked.

navfx

(string) default is "sliding". Define the carousel transition effect. Possible values: "sliding", "none"

scroll

(int) default is equal to 'shownavitems' option value. Defines how many nav thumbnails must be scrolled when nav buttons are clicked. Can't be greater than the 'shownavitems' option value.

scrollspeed

(int) default is 600. Set the nav scroll speed (ms).

scrolleasing

(string) default is "swing". Add an easing effect to the nav slide transition.
Default jQuery easing functions are "swing" or "linear". Other effects can be added with the jQuery easing plugin: http://gsgd.co.uk/sandbox/jquery/easing/.

panelfx

(string) default is "fading". Define the panels transition effect. Possible values: "fading", "sliding", "none"

panelfxspeed

(int) default is 700. Set the panel slide transition effect speed (ms).

panelfxeasing

(string) default is "swing". Add an easing effect to the panel slide transition.
Default jQuery easing functions are "swing" or "linear". Other effects can be added with the jQuery easing plugin: http://gsgd.co.uk/sandbox/jquery/easing/

panelfxfirst (v1.5)

(string) default is "none". Add a transition effect on the first displayed item. There are only 2 possible values for the moment: "fading" or "none".

panelfxbefore

(function) default is function(){}. The function called before the panel transition start.

panelfxafter

(function) default is function(){}. The function called when panel transition is over.

panelbtnshover

(boolean) default is false. If set to true, go buttons will fade in/out on panel mouseover.

verticalnav

(boolean) default is false. Set the nav clip direction to vertical.

verticalslide

(boolean) default is false. Set the panel sliding direction to vertical (only if "panelfx" is defined as "sliding").

tabs

(boolean) default is false. Required to build a tabs menu.

freeheight

(boolean) default is false. Use panels with no fixed height (in this case, 'panelfx' value can't be "sliding").

fastchange

(boolean) default is true. By default the user can slide to the next content even if the slider is still running. You can stop this behavior by setting the "fastchange" option to false.

debug

(boolean) default is false. If set to true, the script will stop on errors and return error code values. Check documentation.

Extending Slider Kit

Fetching the Slider Kit instance

A way of extending Slider Kit is to fetch the instance from anywhere on your page.

jQuery(".anyclassorid").sliderkit(); // initialize the slider object

var mySliderkit = $(".anyclassorid").data("sliderkit"); // 'mySliderkit' is now a sliderkit instance

$('#play').click(function() {
    mySliderkit.autoScrollStart(); // will start slideshow when the element #play is clicked
});

API Methods

autoScrollStart()

Starts the auto scrolling.

autoScrollStop()

Stops the auto scrolling.

playBtnStart()

Starts the auto scrolling and changes the Play button CSS class.

playBtnPause()

Stops the auto scrolling and changes the Play button CSS class.

navPrev()

Scroll the nav to the previous line.

navNext()

Scroll the nav to the next line.

stepBackward()

Displays the previous item in line, or the last if you are at the first item.

stepForward()

Displays the previous item in line, or the last if you are at the first item.

changeWithId( index )

Switches item using the specify index.

selectThumbnail( index )

Highlight item using the specify index.

Troubleshooting

Common errors

If you are having trouble running the plugin, start by checking these basic points:

  • The slider main container must have defined width and height values in the CSS (height can be null if the "freeheight" option is activated).
  • The CSS class names over the HTML tags must be respected (check the HTML elements section).
  • If you are testing a gallery, the panels number must be equal to the navigation thumbnails number.
  • If you are imbricating sliders, they must have different 'cssprefix' values.
  • Globally, many errors come from CSS bugs. In doubt, checking the demos CSS file might help.

Debug mode

To help you finding what's wrong with your plugin installation, you can activate the debug mode option:

debug:true

The script will stop on errors during its execution and display codes:

  • error code 01: (HTML issue) At least a carousel or a panel set must be found in the HTML.
  • error code 02: (CSS issue) You must define the slider height and width values in the CSS.
  • error code 03: (HTML issue) If you are testing a gallery, the panels number must be equal to the navigation thumbnails number.
  • error code 04: (Js issue) Panel easing is set but panel slide is off

Report an issue

If you find an issue using Slider Kit, thanks to report it.

About

Version history

Version 1.5.1

  • bugfix about jQuery selector

Version 1.5

  • 'start' option bug fixed
  • Extending demo added
  • Lightbox demo added

Version 1.4

  • Minimal photo gallery added
  • Small corrections on javascript code

Version 1.3

  • Continuous carousel added

Version 1.2

  • Panel slide transition improved
  • Sliding tabs menu demo added
  • FR version added

Version 1.1

  • Menu demo page added
  • Corrections on demos pages

Thanks to

While developing Slider Kit, I was helped by many excellent jQuery works:
jCarousel, jCarousel Lite, Galleria, Gallery view, Contentflow, Nivo Slider, jQuery Cycle.


Slider Kit packed version is generated through Dean Edwards's packer.


All photos used in the demos pages are from Camille (New York, 2008).

Awards

Softpedia Pick Award