From 62c881cfeb20eed816e3c317e425dc3affa0391d Mon Sep 17 00:00:00 2001 From: siikamiika Date: Mon, 25 Sep 2017 23:47:53 +0300 Subject: Go to next and previous result with Alt+wheel Analogous to Alt+up/down which does the same thing --- ext/mixed/js/display.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'ext') 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(); -- cgit v1.2.3