Skip to content

Commit

Permalink
Merge 82afb3a into af80ade
Browse files Browse the repository at this point in the history
  • Loading branch information
genofire committed Jul 17, 2018
2 parents af80ade + 82afb3a commit 67122b7
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions webroot/js/gui.js
Expand Up @@ -6,15 +6,17 @@ import {singelton as notify} from './element/notify';

const router = new Navigo(null, true, '#'),
elMain = domlib.newEl('main'),
elMenu = new MenuView();
elMenu = new MenuView(),
GUI_RENDER_DEBOUNCER_TIME = 100;

export {router};

let init = false,
currentView = new View();

export function render () {
function renderView () {
if (!document.body) {
window.setTimeout(renderView, GUI_RENDER_DEBOUNCER_TIME);
return;
}

Expand All @@ -26,7 +28,6 @@ export function render () {

init = true;
}

currentView.render();

notify.render();
Expand All @@ -35,6 +36,21 @@ export function render () {
router.resolve();
}

export function render () {
let timeout = false;

function reset () {
timeout = null;
}
if (timeout) {
console('skip rendering to often');
window.clearTimeout(timeout);
}else{
renderView();
}
timeout = window.setTimeout(reset, GUI_RENDER_DEBOUNCER_TIME);
}

export function setView (toView) {
currentView.unbind();
currentView = toView;
Expand Down

0 comments on commit 67122b7

Please sign in to comment.