diff --git a/edit/source-editor.js b/edit/source-editor.js index 5b1d5385..231901c9 100644 --- a/edit/source-editor.js +++ b/edit/source-editor.js @@ -129,6 +129,8 @@ function createSourceEditor(style) { style.enabled = value; }; + $('#header').addEventListener('wheel', headerOnScroll, {passive: true}); + cm.on('changes', () => { dirty.modify('sourceGeneration', savedGeneration, cm.changeGeneration()); updateLintReportIfEnabled(cm); @@ -333,6 +335,20 @@ function createSourceEditor(style) { } } + function headerOnScroll({deltaY, deltaMode, shiftKey}) { + if (deltaY < 0 && this.scrollTop || + deltaY > 0 && this.scrollTop + this.clientHeight < this.scrollHeight) { + return; + } + cm.display.scroller.scrollTop += + // WheelEvent.DOM_DELTA_LINE + deltaMode === 1 ? deltaY * cm.display.cachedTextHeight : + // WheelEvent.DOM_DELTA_PAGE + deltaMode === 2 || shiftKey ? Math.sign(deltaY) * cm.display.scroller.clientHeight : + // WheelEvent.DOM_DELTA_PIXEL + deltaY; + } + return { replaceStyle, save,