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 light and flexible plugin combined with ready-to-use CSS skins.

Features

Demos

Compatibility

Versions

Version 1.4

Version 1.3

Version 1.2

Version 1.1

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):

CSS advices

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.4.min.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.4.min.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.

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/

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:

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:

Report an issue

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

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.