- Overview
- Documents
Welcome to Bare Bones Slider
Bare Bones Slider is a minimalistic jQuery slider. The biggest strength of this slider isn't what it does; it's what it doesn't do. By default, there's very little bloat so developers can add new functionality without having to undo the plugin's "helpful" features. Beginners can use pre-coded options, while experts can control it using public methods.
Why should I use this slider?
- Loads images on demand
- Allows you to make your own pagination and controls
- Public methods that you can call outside of the plugin
- Variables can be retrieved at any time
- Has touch controls for phones
- Lots of options
How to install
1. Link files
Bare Bones slider has a .js and a .css file in addition to the jQuery library. Optionally, you can include the easing plugin for animations.
<!-- Include the stylesheet --> <link type="text/css" href="css/jquery.bbslider.css" rel="stylesheet" media="screen" /> <!-- Include jQuery --> <script src="http://code.jquery.com/jquery-latest.js"></script> <!-- Optional: Include the easing plugin --> <script type="text/javascript" src="js/jquery.easing.1.3.js"></script> <!-- Include the slider plugin --> <script type="text/javascript" src="js/jquery.bbslider.min.js"></script>
2. Create HTML
Create a container for the slider and children for the panels.
<div class="slider"> <div><img src="images/image-1.jpg" alt="first image" /></div> <div><img src="images/image-2.jpg" alt="second image" /></div> <div><img src="images/image-3.jpg" alt="third image" /></div> <div><img src="images/image-4.jpg" alt="forth image" /></div> <div><img src="images/image-5.jpg" alt="fifth image" /></div> </div>
3. Call the slider
Call the slider after the HTML markup.
$('.slider').bbslider({ auto: true, timer: 3000, loop: true });
Options
Option | Default | Parameters | Description | Notes |
---|---|---|---|---|
autoHeight | true | true/false | Automatically sets the height to the largest panel. | The slider must have a set height. If you turn this off, you must set your own. |
page | 1 | Integer | The panel to start on. | |
duration | 1000 | Integer | Duration of transition animation. | |
easing | "swing" | string | Easing of transition animation. | Include and read the easing plugin to use something other than swing. |
controls | false | true/false | Creates prev/next controls. | You can create your own controls even if you turn this off. |
pager | false | true/false | Creates pagination. | You can create your own pager even if you turn this off. The slider must have a unique id for this to work. |
pagerWrap | ".pager-wrap" | Selector | The element to append the pager to. | Only used if pager is on. This must be already on the page when the slider is initiated. |
pageInfo | false | true/false | Display "(current slide) of (total slides)" | |
infoWrap | ".info-wrap" | Selector | The element to append the page info to. | Only used if pageInfo is on. |
onDemand | false | true/false | Loads images as slides are viewed. | Images must be inside a panel container. |
placeholder | "/images/blank.gif" | location | The placeholder image for images not loaded. | Only used if onDemand is on. Not required, but some browsers display an ugly broken icon if it can't find an image. |
auto | false | true/false | Panels play automatically. | |
timer | 5000 | Integer | Timer between slides for auto play. | |
loop | true | true/false | Loops to beginning and end when controls are hit. | |
loopTrans | true | true/false | Use the forward animation when looping back to beginning. | |
transition | fade | none, fade, slide, slideVert, blind | Transition effects between slides. | |
callback | null | Function | Function to run after every slide | |
pauseOnHit | true | true/false | Pause autoplay when someone uses controls or pager | |
randomPlay | false | true/false | Slides are random on auto play | |
touch | false | true/false | Use touch controls for phones and tablets | |
touchoffset | 50 | Integer | Amount of pixels to drag before moving to new slide |
Methods
Public Methods
These functions can be called after initialization to move to various panels. You can also bind your own pagination links; read the pagination section on the examples page for the syntax.
$('#slider').bbslider('next'); $('#slider').bbslider('prev'); $('#slider').bbslider('randomSlide'); $('#slider').bbslider('play'); $('#slider').bbslider('pause'); $('#slider').bbslider('destroy'); $('#slider').bbslider('update'); $('#slider').bbslider('travel',2); $('#clicker').bbslider('bindpager');
Getting data
Data is bound to the slider object and you can retrieve those values anytime.
- pIndex
- cIndex
- pCount
- transition
- easing
- duration
- onDemand
- infoWrap
- callback
- loop
- timer
- loopTrans
- autoPlay
- randomPlay
- placeholder
- pager
- pagerWrap
- autoHeight
autoPlay is whether or not the slider is playing. pIndex is the index for the current panel. cIndex is the index for the previous panel. pCount is for the total number of panels. The rest are the options set at initialization.
var pIndex = $('#slider').data('pIndex'); var cIndex = $('#slider').data('cIndex'); var pCount = $('#slider').data('pCount');
Setting data
You can set any of the above data at any time. Changing the duration, timer, loopTrans, loop, or easing should be safe, but the rest are important to the slider's initialization and should only be for advanced users. Setting the data manually could break the slider.
$('#slider').data('duration',5000);