I've come across this great stack where you can build a vertical carousel. I implemented my own version of the code to make everything slide horizontally.
It works great, but in order for it to work, you have to know how many images the horizontal gallery will going to have so we can adapt the code to it. Otherwise the images goes below the another. I Does anyone know how to adapt the code to the actual width of the gallery?
window.clients = function($elem) {
var left = parseInt($elem.css("left"));
var $cp = $("#clients .client");
var temp = -1 * $cp.width();
var guarda = [];
$cp.each(function () {
quantos.push($(this).width());
});
var quantos = guarda.length();
if(left < temp) {
left = $("#clients").width();
$elem.css("left", left);
}
$elem.animate({ left: (parseInt(left)-230) }, 1000, "linear", function () {
window.clients($(this));
});
};
$(function () {
$(document).ready(function() {
var i = 0;
$("#clients .client").each(function () {
$(this).css("left", i);
i += 230;
window.clients($(this));
});
});
$(".client").hover( function () {
$(this).children("h3").stop().fadeIn("fast");
}, function () {
$(this).children("h3").stop().fadeOut("fast");
});
});