prioritize visible CMs in refreshOnViewListener
This commit is contained in:
parent
a06697808f
commit
b19fd0dabf
|
@ -647,11 +647,18 @@ function SectionsEditor() {
|
||||||
xo.observe(cm.display.wrapper);
|
xo.observe(cm.display.wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @param {IntersectionObserverEntry[]} entries */
|
||||||
function refreshOnViewListener(entries) {
|
function refreshOnViewListener(entries) {
|
||||||
for (const {isIntersecting, target} of entries) {
|
for (const e of entries) {
|
||||||
if (isIntersecting) {
|
const r = e.isIntersecting && e.intersectionRect;
|
||||||
target.CodeMirror.refresh();
|
if (r) {
|
||||||
xo.unobserve(target);
|
xo.unobserve(e.target);
|
||||||
|
const cm = e.target.CodeMirror;
|
||||||
|
if (r.bottom > 0 && r.top < window.innerHeight) {
|
||||||
|
cm.refresh();
|
||||||
|
} else {
|
||||||
|
setTimeout(() => cm.refresh());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user