Skip to content

Commit

Permalink
Merge pull request piskelapp#529 from david-szabo97/hotfix-multiple_p…
Browse files Browse the repository at this point in the history
…iskel_ready_callback

Change onPiskelReady to support multiple callback
  • Loading branch information
juliandescottes committed Aug 29, 2016
2 parents 9c6871e + 53d728c commit 52eaa8b
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/piskel-boot.js
Expand Up @@ -9,7 +9,11 @@
version = '';
}

window.onPiskelReady = function () {
if (!window.piskelReadyCallbacks) {
window.piskelReadyCallbacks = [];
}

window._onPiskelReady = function () {
var loadingMask = document.getElementById('loading-mask');
loadingMask.style.opacity = 0;
window.setTimeout(function () {loadingMask.parentNode.removeChild(loadingMask);}, 600);
Expand All @@ -18,6 +22,11 @@
delete window.pskl_exports;
delete window.loadDebugScripts;
delete window.done;

// Run Piskel ready callbacks
for (var i = 0; i < window.piskelReadyCallbacks.length; i++) {
window.piskelReadyCallbacks[i]();
}
};

var prefixPath = function (path) {
Expand Down Expand Up @@ -50,7 +59,7 @@
var scriptIndex = 0;
window.loadNextScript = function () {
if (scriptIndex == window.pskl_exports.scripts.length) {
window.onPiskelReady();
window._onPiskelReady();
} else {
loadScript(window.pskl_exports.scripts[scriptIndex], 'loadNextScript()');
scriptIndex ++;
Expand All @@ -74,6 +83,6 @@
}

loadStyle('css/piskel-style-packaged' + version + '.css');
loadScript(script, 'onPiskelReady()');
loadScript(script, '_onPiskelReady()');
}
})();

0 comments on commit 52eaa8b

Please sign in to comment.