(function($) {
$.fn.HDWinnersSlider = function(options) {
var defaults = {
animDuration: 1000,
animDelay: 5000
};
var settings = $.extend({}, defaults, options);
var slider = $(this);
if (slider.children().first() && slider.children().first().prop("tagName")) {
var slideItem = slider.children().first().prop("tagName").toLowerCase();
var slideItemsCount = slider.find(slideItem).length;
var slideItemHeight = slider.find(slideItem).first().outerHeight();
slider.css({
"overflow": "hidden",
"height": slideItemHeight * 3
})
function slide() {
slider.find(slideItem).first().animate({
"margin-top": parseInt(slideItemHeight) * -1
}, settings.animDuration, function() {
var firstEl = slider.find(slideItem).first();
var lastEl = slider.find(slideItem).last();
firstEl.insertAfter(lastEl).css("margin-top", 0);
})
}
if (slideItemsCount > 3) {
var autoSlide = setInterval(function() {
slide();
}, settings.animDelay);
slider.hover(function() {
clearInterval(autoSlide);
}, function() {
autoSlide = setInterval(function() {
slide();
}, settings.animDelay);
})
}
}
};
}(jQuery));
$( document ).ready(function() {
$(".hd-winners").HDWinnersSlider({
animDuration: 1000,
animDelay: 2000
});
});