fix resizing of last section if page is scrolled

This commit is contained in:
tophf 2021-01-07 14:46:29 +03:00
parent 39e03b0a9f
commit ac7b33d7e0

View File

@ -361,11 +361,11 @@ function createResizeGrip(cm) {
const resizeGrip = t.template.resizeGrip.cloneNode(true); const resizeGrip = t.template.resizeGrip.cloneNode(true);
wrapper.appendChild(resizeGrip); wrapper.appendChild(resizeGrip);
let lastClickTime = 0; let lastClickTime = 0;
let initHeight; let lastHeight;
let initY; let lastY;
resizeGrip.onmousedown = event => { resizeGrip.onmousedown = event => {
initHeight = wrapper.offsetHeight; lastHeight = wrapper.offsetHeight;
initY = event.pageY; lastY = event.clientY;
if (event.button !== 0) { if (event.button !== 0) {
return; return;
} }
@ -387,9 +387,11 @@ function createResizeGrip(cm) {
document.on('mouseup', resizeStop); document.on('mouseup', resizeStop);
function resize(e) { function resize(e) {
const height = Math.max(minHeight, initHeight + e.pageY - initY); const height = Math.max(minHeight, lastHeight + e.clientY - lastY);
if (height !== wrapper.offsetHeight) { if (height !== lastHeight) {
cm.setSize(null, height); cm.setSize(null, height);
lastHeight = height;
lastY = e.clientY;
} }
} }