1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
(function($){
$.fn.vTicker = function(options) {
var defaults = {
speed: 700,
pause: 8000,
showItems: 1
};
var options = $.extend(defaults, options);
moveUp = function(obj, height){
first = obj.children('ul').children('li:first').clone(true);
obj.children('ul')
.animate({top: '-=' + height + 'px'}, options.speed, function() {
$(this).children('li:first').remove();
$(this).css('top', '0px');
});
first.appendTo(obj.children('ul'));
};
return this.each(function() {
obj = $(this);
maxHeight = 0;
obj.css({overflow: 'hidden', position: 'relative'})
.children('ul').css({position: 'absolute', margin: 0, padding: 0})
.children('li').css({margin: 0, padding: 0});
obj.children('ul').children('li').each(function(){
if($(this).height() > maxHeight)
{
maxHeight = $(this).height();
}
});
obj.children('ul').children('li').each(function(){
$(this).height(maxHeight);
});
obj.height(maxHeight * options.showItems);
interval = setInterval('moveUp(obj, maxHeight)', options.pause);
});
};
})(jQuery); |
Partager