#35 fixed DOM ready event
This commit is contained in:
parent
98cc32cae4
commit
75f8869f7f
|
@ -1,3 +1,5 @@
|
||||||
|
import * as helper from './helpers';
|
||||||
|
|
||||||
let __scripts = [];
|
let __scripts = [];
|
||||||
let __afterLoadScripts = [];
|
let __afterLoadScripts = [];
|
||||||
|
|
||||||
|
@ -16,7 +18,7 @@ export function initCore() {
|
||||||
attributes: true
|
attributes: true
|
||||||
});
|
});
|
||||||
|
|
||||||
document.addEventListener("DOMContentLoaded", event => awaitPageLoaded(), false);
|
helper.onReady(() => awaitPageLoaded());
|
||||||
}
|
}
|
||||||
|
|
||||||
export function registerScript(func, pattern = '.*') {
|
export function registerScript(func, pattern = '.*') {
|
||||||
|
|
|
@ -10,6 +10,14 @@ export function initHelpers() {
|
||||||
document.addEventListener('keyup', event => handleKeyUp(event));
|
document.addEventListener('keyup', event => handleKeyUp(event));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function onReady(fn) {
|
||||||
|
if (document.readyState != 'loading') {
|
||||||
|
fn();
|
||||||
|
} else {
|
||||||
|
document.addEventListener('DOMContentLoaded', fn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function handleKeyDown(event) {
|
function handleKeyDown(event) {
|
||||||
handleKeyToggle(event, true);
|
handleKeyToggle(event, true);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue