limit section's height to viewport

This commit is contained in:
tophf 2022-04-11 14:04:50 +03:00
parent 79ada00a01
commit 3522a53ad4

View File

@ -241,6 +241,7 @@ function createSection(originalSection, genId, si) {
if (appliesTo.length > 1 && appliesTo[0].all) {
removeApply(appliesTo[0]);
}
if (base) requestAnimationFrame(shrinkSectionBy1);
emitSectionChange('apply');
return apply;
}
@ -349,6 +350,15 @@ function createSection(originalSection, genId, si) {
dirty.add(`${dirtyPrefix}.value`, value);
}
}
function shrinkSectionBy1() {
const cmEl = cm.display.wrapper;
const cmH = cmEl.offsetHeight;
const viewH = el.parentElement.offsetHeight;
if (el.offsetHeight > viewH && cmH > Math.min(viewH / 2, cm.display.sizer.offsetHeight + 30)) {
cmEl.style.height = (cmH - appliesToContainer.offsetHeight / (appliesTo.length || 1) | 0) + 'px';
}
}
}
function createResizeGrip(cm) {