Adding auto-scroll to the WooThemes VibrantCMS
One of my clients wanted the featured image slider in the WooThemes VibrantCMS theme to auto-scroll. As I couldn’t find a solution out there, I coded one myself.
Auto-Scroll Demonstration
This video demonstrates the effect achieved by the JavaScript I include in this post:
The Code: VibrantCMS Auto-Scroll JavaScript
To make the featured images auto-scroll in your VibrantCMS theme, you’ll need to add the following code to /vibrantcms/includes/js/featured.js:
Before jQuery(document).ready(function(){ add:
var scrollcount = 1; // a global var used to setup counting between transitions
var scrollinterval = 7000; // time in milliseconds between transitions
var transinterval = 1000; // time in milliseconds for the transition between featured images
function autoscroll(){
var buttontotal = jQuery('#steps ul').children().size();
var marginleft = scrollcount * -960;
jQuery('.widearea').animate({
marginLeft: marginleft + 'px'
},transinterval);
scrollcount++;
if(scrollcount == buttontotal) scrollcount = 0;
}
After jQuery(document).ready(function(){ add:
autoscrollID = setInterval('autoscroll()',scrollinterval);
jQuery('#steps li a').click(function(){
clearInterval(autoscrollID);
});
jQuery('.buttons').click(function(){
clearInterval(autoscrollID);
});
Once you are finished, the complete file will look something like this:
var scrollcount = 1; // a global var used to setup counting between transitions
var scrollinterval = 7000; // time in milliseconds between transitions
var transinterval = 1000; // time in milliseconds for the transition between featured images
function autoscroll(){
var buttontotal = jQuery('#steps ul').children().size();
var marginleft = scrollcount * -960;
jQuery('.widearea').animate({
marginLeft: marginleft + 'px'
},transinterval);
scrollcount++;
if(scrollcount == buttontotal) scrollcount = 0;
}
jQuery(document).ready(function(){
autoscrollID = setInterval('autoscroll()',scrollinterval);
jQuery('#steps li a').click(function(){
clearInterval(autoscrollID);
});
jQuery('.buttons').click(function(){
clearInterval(autoscrollID);
});
// WooThemes auto-scroll code goes here...
});
For those of you who have been hunting for this type of solution, I hope this helps!
Note: I’d call myself an intermediate JavaScript novice. If you see any improvements that can be made in my code, please share them in the comments.


THANK YOU for this!!! Sooo handy and well explained.
Thank you for this code !
I want the Auto-Scroll stops when the mouse is over the slider and restart when the mouse is out… Can you help me please ?
This is a brilliant fix. I have implemented onto a site however i dont suppose you know why at the end of all the slides it goes to a blank one, as opposed to sliding back to the first slide?
Link: http://tur.im/bItpdR
Worked nicely! Thanks for the code!
Thanks, Michael! I’m sure I could have worked this out myself, but the client called and asked for it as I was trying to get out the door to a meeting. The fact that you posted it for others to use is really great of you! Thanks!
Eddy: Awesome! So glad I could help.