/* ========================================================= // jquery.newssticker.js // Author: Arnault PACHOT - apachot@openstudio.fr // Copyright (c) 2007 Cyrille Kazis (http://www.screencom.com/) ========================================================= */ (function($) { $.dequeue = function( a , b ){ return $(a).dequeue(b); }; $.fn.newssticker = function(options) { this.each(function(){ $(this).wrap("
"); var settings = { width: 400, height: 80, view: 2, speed: 2500 }; if(options) $.extend(settings, options); var elements = $(this).children(); var elements_length = elements.length; for ( var i = 0; i < elements_length; i++ ) { $(elements[i]).css('position', 'relative').css('padding-top', 0).css('padding-bottom', '0').css('margin-top', '0').css('margin-bottom', '0').css('height', settings.height+'px').css("overflow", "hidden"); } for ( var i = elements_length-1; i >= 0; i-- ) { $(elements[i]).clone().insertAfter(elements[elements_length-1]); } $(this).parent().css("position", "relative").css("width", settings.width+'px').css("height", (settings.height*settings.view)+'px').css("overflow", "hidden"); $(this).css("position", "absolute").css('padding-top', 0).css('padding-bottom', 0).css('margin-top', 0).css('margin-bottom', 0).css("top", 0).css("left", 0); $(this).bind('mouseover', function(){$(this).stop();}).bind('mouseout', function(){newssticker_animate($(this), elements_length, settings);}); newssticker_animate($(this), elements_length, settings); }); }; function newssticker_animate(current, elements_length, settings) { $(current).animate({'top': "-"+(settings.height*elements_length)+"px"}, parseInt(settings.speed*(elements_length + (parseInt($(current).css('top'))/settings.height))), "linear", function(){$(current).css("top", 0);newssticker_animate(current, elements_length, settings);}) }; $(document).ready(function(){ $("ul.newssticker").newssticker(); }); })(jQuery);