use mousewheel to change focused "input[type=number], select" (#1010)

* use mousewheel to change focused "input[type=number], select"

* revert 0f394fa8 (no longer needed)
This commit is contained in:
tophf 2020-08-02 06:50:12 +03:00 committed by GitHub
parent 0f394fa8d8
commit f8402a2211
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 3 deletions

View File

@ -350,9 +350,6 @@ function createSourceEditor({style, onTitleChanged}) {
} }
function headerOnScroll({target, deltaY, deltaMode, shiftKey}) { function headerOnScroll({target, deltaY, deltaMode, shiftKey}) {
if (target.tagName === 'INPUT' && target.type === 'number') {
return;
}
while ((target = target.parentElement)) { while ((target = target.parentElement)) {
if (deltaY < 0 && target.scrollTop || if (deltaY < 0 && target.scrollTop ||
deltaY > 0 && target.scrollTop + target.clientHeight < target.scrollHeight) { deltaY > 0 && target.scrollTop + target.clientHeight < target.scrollHeight) {

View File

@ -91,6 +91,21 @@ document.addEventListener('click', e => {
e.preventDefault(); e.preventDefault();
} }
}); });
// update inputs on mousewheel when focused
document.addEventListener('wheel', event => {
const el = document.activeElement;
if (!el || el !== event.target && !el.contains(event.target)) {
return;
}
if (el.tagName === 'SELECT') {
el.selectedIndex = Math.max(0, Math.min(el.length - 1, el.selectedIndex + Math.sign(event.deltaY)));
event.preventDefault();
}
event.stopImmediatePropagation();
}, {
capture: true,
passive: false,
});
function onDOMready() { function onDOMready() {
if (document.readyState !== 'loading') { if (document.readyState !== 'loading') {