relay scrolling over #header to usercss code section

This commit is contained in:
tophf 2017-12-07 04:36:46 +03:00
parent d4ffa04bb6
commit 9c8e835a80

View File

@ -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,