Created
April 24, 2012 15:05
-
-
Save dongilbert/2480362 to your computer and use it in GitHub Desktop.
jQuery Cycle Base Container
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* This is a base container for | |
* whenever I use jQuery Cycle. | |
* http://jquery.malsup.com/cycle/ | |
* | |
* Use this as base HTML | |
* | |
* <div id="slider"> | |
* <div id="slides"> | |
* <div class="slide" style="display:block">...</div> | |
* <div class="slide">...</div> | |
* etc.... | |
* </div> | |
* <div id="slidenav"></div> | |
* <div id="slider-prev"></div> | |
* <div id="slider-next"></div> | |
* </div> | |
* | |
* Use this as base CSS | |
* | |
* #slider { | |
* position: relative; | |
* } | |
* #slides .slide { | |
* position: absolute; | |
* top:0; | |
* left:0; | |
* display:none; | |
* } | |
* | |
* Don't forget to style the slidenav and | |
* prev/next. Otherwise remove them. | |
* | |
*/ | |
// Locate the slide container and assign it to a var | |
var slider = $('#slides'); | |
// Bail early if the element doesn't exist | |
if(slider.length > 0) | |
{ | |
slider.cycle({ | |
timeout: 4000, | |
pager: '#slidenav', | |
prev: '#slider-prev', | |
next: '#slider-next', | |
pagerAnchorBuilder: function(idx, slide) | |
{ | |
return '<span></span>'; | |
} | |
}); | |
slider.hover( | |
function(){ | |
// MouseOver | |
slider.cycle('pause'); | |
}, | |
function(){ | |
// MouseOut | |
slider.cycle('resume'); | |
} | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment