Merge pull request #83 from siikamiika/alt-wheel
Go to next and previous result with Alt+wheel
This commit is contained in:
commit
9106b59af6
@ -29,6 +29,7 @@ class Display {
|
|||||||
this.audioCache = {};
|
this.audioCache = {};
|
||||||
|
|
||||||
$(document).keydown(this.onKeyDown.bind(this));
|
$(document).keydown(this.onKeyDown.bind(this));
|
||||||
|
$(document).on('wheel', this.onWheel.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
onError(error) {
|
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) {
|
async termsShow(definitions, options, context) {
|
||||||
try {
|
try {
|
||||||
window.focus();
|
window.focus();
|
||||||
|
Loading…
Reference in New Issue
Block a user