Editor: auto-adjust vertical scrollbar margin for resize grip

This commit is contained in:
tophf 2015-03-26 11:15:40 +03:00
parent 413c454713
commit 827a324297

14
edit.js
View File

@ -205,6 +205,20 @@ function setupCodeMirror(textarea, index) {
document.removeEventListener("mousemove", resize);
});
});
// resizeGrip has enough space when scrollbars.horiz is visible
if (cm.display.scrollbars.horiz.style.display != "") {
cm.display.scrollbars.vert.style.marginBottom = "0";
}
// resizeGrip space adjustment in case a long line was entered/deleted by a user
new MutationObserver(function(mutations) {
var hScrollbar = mutations[0].target;
var hScrollbarVisible = hScrollbar.style.display != "";
var vScrollbar = hScrollbar.parentNode.CodeMirror.display.scrollbars.vert;
vScrollbar.style.marginBottom = hScrollbarVisible ? "0" : "";
}).observe(cm.display.scrollbars.horiz, {
attributes: true,
attributeFilter: ["style"]
});
editors.splice(index || editors.length, 0, cm);
return cm;