render bouncer
This commit is contained in:
parent
af80ade82b
commit
ba1045aacd
|
@ -6,15 +6,17 @@ import {singelton as notify} from './element/notify';
|
||||||
|
|
||||||
const router = new Navigo(null, true, '#'),
|
const router = new Navigo(null, true, '#'),
|
||||||
elMain = domlib.newEl('main'),
|
elMain = domlib.newEl('main'),
|
||||||
elMenu = new MenuView();
|
elMenu = new MenuView(),
|
||||||
|
GUI_RENDER_DEBOUNCER_TIME = 100;
|
||||||
|
|
||||||
export {router};
|
export {router};
|
||||||
|
|
||||||
let init = false,
|
let init = false,
|
||||||
currentView = new View();
|
currentView = new View();
|
||||||
|
|
||||||
export function render () {
|
function renderView () {
|
||||||
if (!document.body) {
|
if (!document.body) {
|
||||||
|
window.setTimeout(renderView, GUI_RENDER_DEBOUNCER_TIME);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +28,6 @@ export function render () {
|
||||||
|
|
||||||
init = true;
|
init = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
currentView.render();
|
currentView.render();
|
||||||
|
|
||||||
notify.render();
|
notify.render();
|
||||||
|
@ -35,6 +36,21 @@ export function render () {
|
||||||
router.resolve();
|
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) {
|
export function setView (toView) {
|
||||||
currentView.unbind();
|
currentView.unbind();
|
||||||
currentView = toView;
|
currentView = toView;
|
||||||
|
|
Loading…
Reference in New Issue