Permalink
Browse files

Merge pull request #22 from dbertram/patch-1

Fix for race condition between the Flickr API call and window load event
  • Loading branch information...
2 parents fd6a516 + 9bf58c1 commit 42b953a4bfde0796aa06a53c5de6d24b360f4adf @samdunn samdunn committed Jul 13, 2011
Showing with 15 additions and 3 deletions.
  1. +15 −3 flickr/js/supersized.flickr.1.1.2.js
@@ -114,7 +114,7 @@
break;
}
-
+ var flickrLoaded = false;
$.ajax({ //request to Flickr
type: 'GET',
url: flickrURL,
@@ -169,7 +169,7 @@
}
/***End load initial images***/
-
+ flickrLoaded = true;
}//End AJAX Callback
});
@@ -182,7 +182,19 @@
resizenow();
});
- $(window).load(function(){
+ $(window).load(function() {
+ ready();
+ });
+
+ var ready = function(){
+ if(flickrLoaded) {
+ loadFunc();
+ } else {
+ setTimeout(ready, 100);
+ }
+ };
+
+ var loadFunc = function(){
$('#supersized-loader').hide(); //Hide loading animation
element.fadeIn('fast'); //Fade in background

0 comments on commit 42b953a

Please sign in to comment.