Skip to content

Commit

Permalink
Merge pull request #2230 from chaffeqa/patch-2
Browse files Browse the repository at this point in the history
fix(load): correctly handle window loaded states
  • Loading branch information
adamdbradley committed Sep 17, 2014
2 parents 9a57845 + 6b29d44 commit a1af665
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions js/utils/platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,8 @@

var platformName = null, // just the name, like iOS or Android
platformVersion = null, // a float of the major and minor, like 7.1
readyCallbacks = [];
readyCallbacks = [],
windowLoadListenderAttached;

// setup listeners to know when the device is ready to go
function onWindowLoad() {
Expand All @@ -364,8 +365,17 @@
// cordova/phonegap object, so its just a browser, not a webview wrapped w/ cordova
onPlatformReady();
}
window.removeEventListener("load", onWindowLoad, false);
if (windowLoadListenderAttached){
window.removeEventListener("load", onWindowLoad, false);
}
}
if (document.readyState === 'complete') {
onWindowLoad();
} else {
windowLoadListenderAttached = true;
window.addEventListener("load", onWindowLoad, false);
}

window.addEventListener("load", onWindowLoad, false);

function onPlatformReady() {
Expand Down

0 comments on commit a1af665

Please sign in to comment.