mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
Merge pull request #529 from david-szabo97/hotfix-multiple_piskel_ready_callback
Change onPiskelReady to support multiple callback
This commit is contained in:
commit
52eaa8b170
@ -9,7 +9,11 @@
|
|||||||
version = '';
|
version = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
window.onPiskelReady = function () {
|
if (!window.piskelReadyCallbacks) {
|
||||||
|
window.piskelReadyCallbacks = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
window._onPiskelReady = function () {
|
||||||
var loadingMask = document.getElementById('loading-mask');
|
var loadingMask = document.getElementById('loading-mask');
|
||||||
loadingMask.style.opacity = 0;
|
loadingMask.style.opacity = 0;
|
||||||
window.setTimeout(function () {loadingMask.parentNode.removeChild(loadingMask);}, 600);
|
window.setTimeout(function () {loadingMask.parentNode.removeChild(loadingMask);}, 600);
|
||||||
@ -18,6 +22,11 @@
|
|||||||
delete window.pskl_exports;
|
delete window.pskl_exports;
|
||||||
delete window.loadDebugScripts;
|
delete window.loadDebugScripts;
|
||||||
delete window.done;
|
delete window.done;
|
||||||
|
|
||||||
|
// Run Piskel ready callbacks
|
||||||
|
for (var i = 0; i < window.piskelReadyCallbacks.length; i++) {
|
||||||
|
window.piskelReadyCallbacks[i]();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var prefixPath = function (path) {
|
var prefixPath = function (path) {
|
||||||
@ -50,7 +59,7 @@
|
|||||||
var scriptIndex = 0;
|
var scriptIndex = 0;
|
||||||
window.loadNextScript = function () {
|
window.loadNextScript = function () {
|
||||||
if (scriptIndex == window.pskl_exports.scripts.length) {
|
if (scriptIndex == window.pskl_exports.scripts.length) {
|
||||||
window.onPiskelReady();
|
window._onPiskelReady();
|
||||||
} else {
|
} else {
|
||||||
loadScript(window.pskl_exports.scripts[scriptIndex], 'loadNextScript()');
|
loadScript(window.pskl_exports.scripts[scriptIndex], 'loadNextScript()');
|
||||||
scriptIndex ++;
|
scriptIndex ++;
|
||||||
@ -74,6 +83,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
loadStyle('css/piskel-style-packaged' + version + '.css');
|
loadStyle('css/piskel-style-packaged' + version + '.css');
|
||||||
loadScript(script, 'onPiskelReady()');
|
loadScript(script, '_onPiskelReady()');
|
||||||
}
|
}
|
||||||
})();
|
})();
|
Loading…
Reference in New Issue
Block a user