editor: use MouseEvent.pageY in resizeGrip

This commit is contained in:
tophf 2017-06-18 12:27:00 +03:00
parent 050109428c
commit c4f871b4ed

View File

@ -360,9 +360,13 @@ function setupCodeMirror(textarea, index) {
var cm = e.target.parentNode.CodeMirror;
var minHeight = cm.defaultTextHeight()
+ cm.display.lineDiv.offsetParent.offsetTop /* .CodeMirror-lines padding */
+ cm.display.wrapper.offsetHeight - cm.display.wrapper.scrollHeight /* borders */;
+ cm.display.wrapper.offsetHeight - cm.display.wrapper.clientHeight /* borders */;
function resize(e) {
cm.setSize(null, Math.max(minHeight, cm.display.wrapper.scrollHeight + e.movementY));
const cmPageY = cm.display.wrapper.getBoundingClientRect().top + window.scrollY;
const height = Math.max(minHeight, e.pageY - cmPageY);
if (height != cm.display.wrapper.clientHeight) {
cm.setSize(null, height);
}
}
document.addEventListener("mousemove", resize);
document.addEventListener("mouseup", function resizeStop() {