From ef922ee862c148244f732c8655e4d36a76e4aba0 Mon Sep 17 00:00:00 2001 From: tophf Date: Thu, 30 Dec 2021 00:23:29 +0300 Subject: [PATCH] cosmetics --- edit/header-resizer.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/edit/header-resizer.js b/edit/header-resizer.js index 8cec6d63..910caf80 100644 --- a/edit/header-resizer.js +++ b/edit/header-resizer.js @@ -6,6 +6,7 @@ (function HeaderResizer() { const el = $('#header-resizer'); let lastW, lastX; + el.onmousedown = e => { if (e.button) return; lastW = $('#header').clientWidth; @@ -14,18 +15,19 @@ document.on('mousemove', resize); document.on('mouseup', resizeStop); }; + function resize({clientX: x}) { const w = editor.updateHeaderWidth(lastW + x - lastX); const delta = w - lastW; - if (delta) { - lastW = w; - lastX = x; - prefs.set('editor.headerWidth', w); - for (const el of $$('.CodeMirror-linewidget[style*="width:"]')) { - el.style.width = parseFloat(el.style.width) - delta + 'px'; - } + if (!delta) return; + lastW = w; + lastX = x; + prefs.set('editor.headerWidth', w); + for (const el of $$('.CodeMirror-linewidget[style*="width:"]')) { + el.style.width = parseFloat(el.style.width) - delta + 'px'; } } + function resizeStop() { document.off('mouseup', resizeStop); document.off('mousemove', resize);