From c4f871b4ed94e6746823eedfe24e7943f1096f78 Mon Sep 17 00:00:00 2001 From: tophf Date: Sun, 18 Jun 2017 12:27:00 +0300 Subject: [PATCH] editor: use MouseEvent.pageY in resizeGrip --- edit.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/edit.js b/edit.js index 119b22cd..ad3e763b 100644 --- a/edit.js +++ b/edit.js @@ -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() {