Skip to content

Commit

Permalink
Merge branch 'master' of github.com:driftyco/ionic
Browse files Browse the repository at this point in the history
  • Loading branch information
perrygovier committed Sep 17, 2014
2 parents e608bad + a1af665 commit 83d58d3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
9 changes: 6 additions & 3 deletions js/utils/dom.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(function(window, document, ionic) {

var readyCallbacks = [];
var isDomReady = false;
var isDomReady = document.readyState === 'complete' || document.readyState === 'interactive';

function domReady() {
isDomReady = true;
Expand All @@ -11,7 +11,10 @@
readyCallbacks = [];
document.removeEventListener('DOMContentLoaded', domReady);
}
document.addEventListener('DOMContentLoaded', domReady);
if (!isDomReady){
document.addEventListener('DOMContentLoaded', domReady);
}


// From the man himself, Mr. Paul Irish.
// The requestAnimationFrame polyfill
Expand Down Expand Up @@ -110,7 +113,7 @@
* @param {function} callback The function to be called.
*/
ready: function(cb) {
if(isDomReady || document.readyState === "complete") {
if(isDomReady) {
ionic.requestAnimationFrame(cb);
} else {
readyCallbacks.push(cb);
Expand Down
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 83d58d3

Please sign in to comment.