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);