serrrgggeee,
(function($) {
$.fn.scrollbox = function(config) {
//default config
defConfig = {
step: 50, // Distance of each single step (in pixels)
speed: 32, // Delay after each single step (in milliseconds)
switchItems: 1, // Items to switch after each scroll event
direction: 'vertical',
distance: 'auto',
};
config = $.extend(defConfig, config);
config.scrollOffset = config.direction === 'vertical' ? 'scrollTop' : 'scrollLeft';
return this.each(function() {
var container = $(this),
containerUL,
nextScrollId = null,
forward,
scrollForward,
containerUL = container.children('ul:first-child');
scrollForward = function() {
containerUL.children('li').removeClass('scale80 scale90 scale100 leftSide rightSide');
containerUL.children('li:nth-child(1)').addClass('scale80 leftSide');
containerUL.children('li:nth-child(2)').addClass('scale90 leftSide');
containerUL.children('li:nth-child(3)').addClass('scale100');
containerUL.children('li:nth-child(4)').addClass('scale90 rightSide');
containerUL.children('li:nth-child(5)').addClass('scale80 rightSide');
};
forward = function() {
scrollingId = setInterval(scrollForward, config.speed);
};
// bind events for container
container.bind('forward', function() { clearTimeout(nextScrollId);containerUL.append(containerUL.children('li:nth-child(1)')) ; forward();});
container.bind('backward', function() { clearTimeout(nextScrollId);containerUL.prepend(containerUL.children('li:nth-child(5)')) ; forward();});
});
};
}(jQuery));