render bouncer

This commit is contained in:
Martin/Geno 2018-07-17 23:54:11 +02:00 committed by Geno
parent af80ade82b
commit ba1045aacd
1 changed files with 19 additions and 3 deletions

View File

@ -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;
}
@ -26,7 +28,6 @@ export function render () {
init = true;
}
currentView.render();
notify.render();
@ -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;