Revert "Add: scroll the editor when cursor is outside of the editor"

This reverts commit 5a9ac5ce7d.
This commit is contained in:
eight 2017-09-16 07:33:12 +08:00
parent a73493d5d2
commit 4d6f856473

View File

@ -46,38 +46,6 @@ function createSourceEditor(style) {
initLint();
initAppliesToReport(cm);
window.addEventListener('wheel', e => {
if (e.target.closest('.CodeMirror') || parentScrollable(e.target)) {
return;
}
const DELTA_MULTIPLIER = [1, 20, window.innerHeight];
scrollBy(
cm.getWrapperElement().querySelector('.CodeMirror-scroll'),
e.deltaY * DELTA_MULTIPLIER[e.deltaMode]
);
}, {passive: true});
function parentScrollable(node) {
while (node) {
if (node.offsetHeight < node.scrollHeight) {
const {overflow} = getComputedStyle(node);
if (overflow === 'auto' || overflow === 'scroll') {
return true;
}
}
node = node.parentNode;
}
return false;
}
function scrollBy(el, offset) {
if (el.scrollBy) {
el.scrollBy({top: offset * 40, behavior: 'smooth'});
} else {
el.scrollTop += offset;
}
}
function initAppliesToReport(cm) {
const APPLIES_TYPE = [
[t('appliesUrlOption'), 'url'],