Skip to content
This repository has been archived by the owner on Jun 14, 2020. It is now read-only.

Commit

Permalink
Added timer fix into core.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Leigh Caplan committed Aug 24, 2011
1 parent ee955f4 commit 12f2776
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/core.js
Expand Up @@ -326,13 +326,20 @@ function QTip(target, options, id, attr)
// Skip if the src is already present
if(srcs[elem.src] !== undefined) { return; }

// Keep track of how many times we poll for image dimensions.
// If it doesn't return in a reasonable amount of time, it's better
// to display the tooltip, rather than hold up the queue.
var iterations = 0, maxIterations = 3;

(function timer(){
// When the dimensions are found, remove the image from the queue
if(elem.height || elem.width) { return imageLoad(elem); }
if(elem.height || elem.width || (iterations > maxIterations)) { return imageLoad(elem); }

iterations += 1;

// Restart timer
self.timers.img[elem.src] = setTimeout(timer, 700);
}());
}());

// Also apply regular load/error event handlers
$(elem).bind('error'+namespace+' load'+namespace, function(){ imageLoad(this); });
Expand Down

0 comments on commit 12f2776

Please sign in to comment.