optimize window resizing

This commit is contained in:
ed 2022-04-09 19:20:09 +02:00
parent dbabeb9692
commit e40cd2a809
2 changed files with 13 additions and 3 deletions

View file

@ -703,8 +703,12 @@ var widget = (function () {
return false;
clmod(document.documentElement, 'np_open', is_open);
widget.className = is_open ? 'open' : '';
clmod(widget, 'open', is_open);
bcfg_set('au_open', r.is_open = is_open);
if (window.vbar) {
pbar.onresize();
vbar.onresize();
}
return true;
};
r.toggle = function (e) {
@ -753,7 +757,7 @@ var widget = (function () {
};
r.set(sread('au_open') == 1);
setTimeout(function () {
clmod(ebi('widget'), 'anim', 1);
clmod(widget, 'anim', 1);
}, 10);
return r;
})();
@ -794,6 +798,9 @@ var pbar = (function () {
grad;
r.onresize = function () {
if (!widget.is_open && r.buf)
return;
r.buf = canvas_cfg(ebi('barbuf'));
r.pos = canvas_cfg(ebi('barpos'));
r.drawbuf();
@ -895,6 +902,9 @@ var vbar = (function () {
can, ctx, w, h, grad1, grad2;
r.onresize = function () {
if (!widget.is_open && r.can)
return;
r.can = canvas_cfg(ebi('pvol'));
can = r.can.can;
ctx = r.can.ctx;

View file

@ -1933,6 +1933,7 @@ function up2k_init(subtle) {
//
function onresize(e) {
// 10x faster than matchMedia('(min-width
var bar = ebi('ops'),
wpx = window.innerWidth,
fpx = parseInt(getComputedStyle(bar)['font-size']),
@ -1942,7 +1943,6 @@ function up2k_init(subtle) {
parent = ebi(wide && write ? 'u2btn_cw' : 'u2btn_ct'),
btn = ebi('u2btn');
//console.log([wpx, fpx, wem]);
if (btn.parentNode !== parent) {
parent.appendChild(btn);
ebi('u2conf').setAttribute('class', wide);