aboutsummaryrefslogtreecommitdiff
path: root/ext/mixed/js/display.js
diff options
context:
space:
mode:
authorsiikamiika <siikamiika@users.noreply.github.com>2017-09-25 23:47:53 +0300
committersiikamiika <siikamiika@users.noreply.github.com>2017-09-25 23:47:53 +0300
commit62c881cfeb20eed816e3c317e425dc3affa0391d (patch)
treebcf33d2fb1a118f1939c1e1e2ab1d2dd07a1370b /ext/mixed/js/display.js
parent18c59bdadb4df704e7bb1bb1af58ea237a5d9685 (diff)
Go to next and previous result with Alt+wheel
Analogous to Alt+up/down which does the same thing
Diffstat (limited to 'ext/mixed/js/display.js')
-rw-r--r--ext/mixed/js/display.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js
index 75ee339a..302a6280 100644
--- a/ext/mixed/js/display.js
+++ b/ext/mixed/js/display.js
@@ -29,6 +29,7 @@ class Display {
this.audioCache = {};
$(document).keydown(this.onKeyDown.bind(this));
+ $(document).on('wheel', this.onWheel.bind(this));
}
onError(error) {
@@ -202,6 +203,25 @@ class Display {
}
}
+ onWheel(e) {
+ const event = e.originalEvent;
+ const handler = () => {
+ if (event.altKey) {
+ if (event.deltaY < 0) { // scroll up
+ this.entryScrollIntoView(this.index - 1, true);
+ return true;
+ } else if (event.deltaY > 0) { // scroll down
+ this.entryScrollIntoView(this.index + 1, true);
+ return true;
+ }
+ }
+ };
+
+ if (handler()) {
+ event.preventDefault();
+ }
+ }
+
async termsShow(definitions, options, context) {
try {
window.focus();