Skip to content

Instantly share code, notes, and snippets.

@johnbhartley
Created February 16, 2014 18:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnbhartley/9038681 to your computer and use it in GitHub Desktop.
Save johnbhartley/9038681 to your computer and use it in GitHub Desktop.
Simple Rotator
// jQuery
function cycleReviews(){
var $active = $('.content-slider .current');
var $next = ($active.next().length > 0) ? $active.next() : $('.content-slider div:first');
$active.fadeOut(500,function(){
$(this).removeClass('current');
$next.fadeIn().addClass('current');
});
var maxHeight = 0;
var tmpHeight = $next.height() + $next.position().top;
console.log('tmp' + tmpHeight);
if (tmpHeight > maxHeight) {
maxHeight = tmpHeight;
$('.content-slider').height(maxHeight);
}
}
$(document).ready(function(){
setInterval('cycleReviews()', 7000);
});
// CSS involved
.content-slider{
position:relative;
clear: both;
-webkit-transition: height 2s;
transition:height 2s;
}
.content-slider .fade{position:absolute;z-index:1; background: #fff; display: none;}
.content-slider .fade.current{z-index:3; display: block;}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment