Permalink
Browse files

Fixing bug that breaks the ticker when have more than one ul elements…

… in the same page.
  • Loading branch information...
1 parent 5eb3b45 commit 1dc1d3587e7f80f06ef6a1e508e686881a5d874f @danielvlopes committed Apr 4, 2010
Showing with 15 additions and 12 deletions.
  1. +15 −12 jquery.ticker.js
View
@@ -2,22 +2,25 @@ jQuery.fn.ticker = function(settings) {
var current=0;
var paused=0;
- var newsTicker = $(this)
+ var newsTicker = $(this);
+ var itemsCollection = newsTicker.find('li');
- var newsitems = newsTicker.find('li').hide().hover(
- function(){ paused=1; },
- function(){ paused=0; }
- ).filter(":eq(0)").show().add("li").size();
+ itemsCollection.hide().filter(":eq(0)").show().add("li");
+
+ itemsCollection.hover(
+ function(){ paused=1; },
+ function(){ paused=0; }
+ );
function ticknews() {
- if (!paused){
- newsTicker.find("li:eq("+current+")").fadeOut("slow",function(){
- $(this).hide();
- });
+ if (paused){ return; };
+
+ newsTicker.find("li:eq("+current+")").fadeOut("slow",function(){
+ $(this).hide();
+ });
- current = ++current%newsitems;
- newsTicker.find("li:eq("+current+")").fadeIn("slow");
- }
+ current = ++current%itemsCollection.size();
+ newsTicker.find("li:eq("+current+")").fadeIn("slow");
}
setInterval(ticknews,4000);

0 comments on commit 1dc1d35

Please sign in to comment.