Simplify onWheel handler

This commit is contained in:
toasted-nutbread 2019-10-02 20:57:48 -04:00
parent 0d6177398d
commit 7380ada1f1

View File

@ -161,22 +161,14 @@ class Display {
} }
onWheel(e) { onWheel(e) {
const handler = () => {
if (e.altKey) { if (e.altKey) {
if (e.deltaY < 0) { // scroll up const delta = e.deltaY;
this.entryScrollIntoView(this.index - 1, null, true); if (delta !== 0) {
return true; this.entryScrollIntoView(this.index + (delta > 0 ? 1 : -1), null, true);
} else if (e.deltaY > 0) { // scroll down
this.entryScrollIntoView(this.index + 1, null, true);
return true;
}
}
};
if (handler()) {
e.preventDefault(); e.preventDefault();
} }
} }
}
async termsShow(definitions, options, context) { async termsShow(definitions, options, context) {
try { try {