Skip to content

Instantly share code, notes, and snippets.

@josephbergdoll
Created March 9, 2015 22:56
Show Gist options
  • Save josephbergdoll/25ea1c0b1cd95129c70b to your computer and use it in GitHub Desktop.
Save josephbergdoll/25ea1c0b1cd95129c70b to your computer and use it in GitHub Desktop.
// Aritst Card Hover Thumb Interval
$('.artist-card.more-thumbs').each(function() {
var
thumb = '.image-thumb',
$thumb = $(this).find('.image-thumb'),
activeClass = 'thumb-active',
activeSelector = '.thumb-active';
$(this).mouseenter(function() {
var $this = $(this);
if ($this.find(activeSelector).next(thumb).length) {
$this.find(activeSelector).removeClass(activeClass).next(thumb).addClass(activeClass);
}
else {
$this.find(activeSelector).removeClass(activeClass);
$thumb.first().addClass(activeClass);
}
cycleThumbs = setInterval( function() {
var
$activeThumb = $this.find('.thumb-active'),
$next = $activeThumb.next(thumb);
if ($next.length) {
$activeThumb.removeClass(activeClass);
$next.addClass(activeClass)
}
else {
$activeThumb.removeClass(activeClass);
$thumb.first().addClass(activeClass);
}
}, 1000);
});
$(this).mouseleave(function() {
clearInterval(cycleThumbs);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment