An agnostic, fluid jQuery content slider that is easily configurable and styleable.
Install via bower bower install jquery.plusslider --save
. Alternatively, install the Angular version via bower bower install angular-plusslider --save
.
$('#slider').plusSlider({
/* General */
sliderType : 'slider', // Choose whether the carousel is a 'slider' or a 'fader'
infiniteSlide : true, // Gives the effect that the slider doesn't ever "repeat" and just continues forever
disableLoop : false, // Disables prev or next buttons if they are on the first or last slider respectively. 'first' only disables the previous button, 'last' disables the next and 'both' disables both
/* Display related */
defaultSlide : 0, // Sets the default starting slide - Number based on item index
displayTime : 4000, // The amount of time the slide waits before automatically moving on to the next one. This requires 'autoPlay: true'
sliderEasing : 'linear', // Anything other than 'linear' and 'swing' requires the easing plugin
speed : 500, // The amount of time it takes for a slide to fade into another slide
/* Functioanlity related */
autoPlay : true, // Creats a times, looped 'slide-show'
keyboardNavigation : true, // The keyboard's directional left and right arrows function as next and previous buttons
pauseOnHover : true, // AutoPlay does not continue ifsomeone hovers over Plus Slider.
/* Arrow related */
createArrows : true, // Creates forward and backward navigation
arrowsPosition : 'prepend', //Where to insert arrows in relation to the slider ('before', 'prepend', 'append', or 'after')
nextText : 'Next', // Adds text to the 'next' trigger
prevText : 'Previous', // Adds text to the 'prev' trigger
/* Pagination related */
createPagination : true, // Creates Numbered pagination
paginationPosition : 'append', // Where to insert pagination in relation to the slider element ('before', 'prepend', 'append', or 'after')
paginationWidth : false, // Automatically gives the pagination a dynamic width
/* Callbacks */
onInit : null, // Callback function: On slider initialize
onSlide : null, // Callback function: As the slide starts to animate
afterSlide : null, // Callback function: As the slide completes the animation
onSlideEnd : null, // Callback function: Once the slider reaches the last slide
// Slider namespace
namespace: 'plusslider',
eventNamespace: 'plusslider',
// Slider class names.
// Note: All names are automatically prepended with namespace
attrNames: {
'elClass' : '',
'elActiveClass' : '--active',
'elTypeSliderClass' : '--type-slider',
'elTypeFaderClass' : '--type-fader',
'containerClass' : '__container',
'slideListClass' : '__slide-list',
'slideItemClass' : '__slide-item',
'slideItemActiveClass': '__slide--active',
'slideItemCloneClass' : '__slide--clone',
'arrowClass' : '__arrow',
'arrowListClass' : '__arrow-list',
'arrowItemClass' : '__arrow-item',
'arrowItemPrevClass' : '__arrow-item--prev',
'arrowItemNextClass' : '__arrow-item--next',
'pagiClass' : '__pagi',
'pagiListClass' : '__pagi-list',
'pagiItemClass' : '__pagi-item',
'pagiItemActiveClass' : '__pagi-item--active'
}
});
The following are the PlusSlider values you may use within the callback functions. Property names beginning with $
( dollar sign ) are referencing a jQuery object, methods are referenced by ending in ()
( open parentheses, close parentheses ) and the rest contain a number value. Look at the code for more variables available for access.
base.$slider // References the original object
base.$sliderContainer // References the outside .plusslider jQuery object
base.$sliderList // References Slider container wrapping base.$sliderList
base.$sliderItems // References all jQuery slide objects within base.$sliderList
base.slideCount // A numerical value of the amount of slides
base.slideIndexCount // The index value of the amount of slides
base.sliderWidth //Stores the slider width value. This changes on resize
base.animating // Boolean - true means the slider is busy animating.
base.wrapContainerWidth // A numerical value of the width of base.$slider
base.wrapContainerHeight // A numerical value of the height of base.$slider
base.activeSlideIndex // References the index number of the current slide
base.$sliderItemsActive // References the current/active slide's jQuery object
base.activeSlideWidth // References a numerical value of the width of the current/active slide
base.activeSlideHeight // References a numerical value of the height of the current/active slide
base.beginTimer() // Method that begins the autoPlay timer
base.clearTimer() // Method that resets the autoPlay timer
base.toSlide() // Will change the current/active slide - Accepts 'next', 'prev' or an index number value as well as a callback
If you wish to make use of the slider methods and properties outside of the callback functions, you would need to initialize the slider in a slightly different way:
var slider;
$(document).ready(function(){
slider = new $.plusSlider($('#slider'), {});
});
slider.toSlide('next); //move slider to next slide
slider.toSlide('prev', function(sliderObj){
// callback here
}); //move slider to previous slide
slider.toSlide(3); //move slider to arbitrary index (first slide is 0, second is 1, etc.)
The default example is a great demonstration of what you can do with PlusSlider, but you probably want to customize the slider to match your site's design. Check out this easy 12-step tutorial on how to customize the design of PlusSlider.
A destroy()
function has now been added. This is convenient for javascript apps when it's important to completely remove a component from memory to prevent memory leaks.
$('#slider').plusSlider('toSlide', 2)
<div>
s.$(el).plusSlider('toSlide', { slide: 'next', callback: function(base){} })
fullWidth
option was integrated into the plugin by defaultinifiniteScroll
fullWidth
fullWidth
bugsonStart
and onEnd
callback functions to onInit
and onSlideEnd
respectivelyfullWidth
width
and height
paginationThumbnails
optionpaginationWidth
to default to falseautoPlay
to autoPlay
defaultSlide
option.plusslide-container
class to the .child
parentnextText
and prevText
optionspaginationThumbnails
optionnextSlide()
functionality to toSlide()
(accepts 'next' and 'prev' as arg values)nextSlide()
function (now that it's functionality is in toSlide())onSlide
callback option - jordanlev
toSlide()
function - jordanlev
width
& height
option