From ac7b33d7e02622d5f3a103eb733542fae41c316c Mon Sep 17 00:00:00 2001 From: tophf Date: Thu, 7 Jan 2021 14:46:29 +0300 Subject: [PATCH] fix resizing of last section if page is scrolled --- edit/sections-editor-section.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/edit/sections-editor-section.js b/edit/sections-editor-section.js index d0086d36..71e53e5d 100644 --- a/edit/sections-editor-section.js +++ b/edit/sections-editor-section.js @@ -361,11 +361,11 @@ function createResizeGrip(cm) { const resizeGrip = t.template.resizeGrip.cloneNode(true); wrapper.appendChild(resizeGrip); let lastClickTime = 0; - let initHeight; - let initY; + let lastHeight; + let lastY; resizeGrip.onmousedown = event => { - initHeight = wrapper.offsetHeight; - initY = event.pageY; + lastHeight = wrapper.offsetHeight; + lastY = event.clientY; if (event.button !== 0) { return; } @@ -387,9 +387,11 @@ function createResizeGrip(cm) { document.on('mouseup', resizeStop); function resize(e) { - const height = Math.max(minHeight, initHeight + e.pageY - initY); - if (height !== wrapper.offsetHeight) { + const height = Math.max(minHeight, lastHeight + e.clientY - lastY); + if (height !== lastHeight) { cm.setSize(null, height); + lastHeight = height; + lastY = e.clientY; } }