cover up most of the layout jank

This commit is contained in:
ed 2023-01-30 22:52:16 +00:00
parent f74ac1f18b
commit 8c54c2226f
2 changed files with 34 additions and 1 deletions

View file

@ -121,7 +121,7 @@
<div id="epi" class="logue">{{ "" if sb_lg else logues[1] }}</div>
<h2><a href="{{ r }}/?h" id="goh">control-panel</a></h2>
<h2 id="wfp"><a href="{{ r }}/?h" id="goh">control-panel</a></h2>
<a href="#" id="repl">π</a>

View file

@ -5726,6 +5726,32 @@ function despin(sel) {
}
var wfp_debounce = (function () {
var r = { 'n': 0, 't': 0 };
r.hide = function () {
if (++r.n <= 1) {
r.n = 1;
clearTimeout(r.t);
r.t = setTimeout(r.reset, 500);
ebi('wfp').style.visibility = 'hidden';
}
};
r.show = function () {
if (--r.n <= 0) {
r.n = 0;
clearTimeout(r.t);
ebi('wfp').style.visibility = 'unset';
}
};
r.reset = function () {
r.n = 0;
r.show();
};
return r;
})();
function apply_perms(newperms) {
perms = newperms || [];
@ -6616,10 +6642,12 @@ function show_md(md, name, div, url, depth) {
if (url != now)
return;
wfp_debounce.hide();
if (!marked) {
if (depth)
return toast.warn(10, errmsg + 'failed to load marked.js')
wfp_debounce.n--;
return import_js(SR + '/.cpr/deps/marked.js', function () {
show_md(md, name, div, url, 1);
});
@ -6675,6 +6703,7 @@ function show_md(md, name, div, url, depth) {
catch (ex) {
toast.warn(10, errmsg + ex);
}
wfp_debounce.show();
}
@ -6702,6 +6731,9 @@ function sandbox(tgt, rules, cls, html) {
return false;
}
clmod(tgt, 'sb', 1);
if (!cls)
wfp_debounce.hide();
var tid = tgt.getAttribute('id'),
hash = location.hash,
want = '';
@ -6752,6 +6784,7 @@ window.addEventListener("message", function (e) {
var el = QS(t[1] + '>iframe');
el.style.height = t[2] + 'px';
el.style.visibility = 'unset';
wfp_debounce.show();
}
else if (t[0] == 'iscroll') {
var y1 = QS(t[1]).offsetTop,