refactoring and optimization
This commit is contained in:
parent
f4a987912a
commit
83460bcdad
@ -497,21 +497,23 @@ class Frontend {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static isMouseButton(button, mouseEvent) {
|
static isMouseButton(button, mouseEvent) {
|
||||||
if (['mouseup', 'mousedown', 'click'].includes(mouseEvent.type)) {
|
switch (mouseEvent.type) {
|
||||||
switch (button) {
|
case 'mouseup':
|
||||||
|
case 'mousedown':
|
||||||
|
case 'click': switch (button) {
|
||||||
case 'primary': return mouseEvent.button === 0;
|
case 'primary': return mouseEvent.button === 0;
|
||||||
case 'secondary': return mouseEvent.button === 2;
|
case 'secondary': return mouseEvent.button === 2;
|
||||||
case 'auxiliary': return mouseEvent.button === 1;
|
case 'auxiliary': return mouseEvent.button === 1;
|
||||||
default: return false;
|
default: return false;
|
||||||
}
|
}
|
||||||
}
|
default: switch (button) {
|
||||||
switch (button) {
|
|
||||||
case 'primary': return (mouseEvent.buttons & 0x1) !== 0x0;
|
case 'primary': return (mouseEvent.buttons & 0x1) !== 0x0;
|
||||||
case 'secondary': return (mouseEvent.buttons & 0x2) !== 0x0;
|
case 'secondary': return (mouseEvent.buttons & 0x2) !== 0x0;
|
||||||
case 'auxiliary': return (mouseEvent.buttons & 0x4) !== 0x0;
|
case 'auxiliary': return (mouseEvent.buttons & 0x4) !== 0x0;
|
||||||
default: return false;
|
default: return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Frontend.windowMessageHandlers = {
|
Frontend.windowMessageHandlers = {
|
||||||
|
@ -82,7 +82,7 @@ class Display {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onGlossaryMousedown(e) {
|
onGlossaryMouseDown(e) {
|
||||||
if (Frontend.isMouseButton('primary', e)) {
|
if (Frontend.isMouseButton('primary', e)) {
|
||||||
this.clickScanPrevent = false;
|
this.clickScanPrevent = false;
|
||||||
}
|
}
|
||||||
@ -92,7 +92,7 @@ class Display {
|
|||||||
this.clickScanPrevent = true;
|
this.clickScanPrevent = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
onGlossaryMouseup(e) {
|
onGlossaryMouseUp(e) {
|
||||||
if (!this.clickScanPrevent && Frontend.isMouseButton('primary', e)) {
|
if (!this.clickScanPrevent && Frontend.isMouseButton('primary', e)) {
|
||||||
this.onTermLookup(e);
|
this.onTermLookup(e);
|
||||||
}
|
}
|
||||||
@ -269,8 +269,8 @@ class Display {
|
|||||||
this.addEventListeners('.kanji-link', 'click', this.onKanjiLookup.bind(this));
|
this.addEventListeners('.kanji-link', 'click', this.onKanjiLookup.bind(this));
|
||||||
this.addEventListeners('.source-term', 'click', this.onSourceTermView.bind(this));
|
this.addEventListeners('.source-term', 'click', this.onSourceTermView.bind(this));
|
||||||
if (this.options.scanning.enablePopupSearch) {
|
if (this.options.scanning.enablePopupSearch) {
|
||||||
this.addEventListeners('.glossary-item', 'mouseup', this.onGlossaryMouseup.bind(this));
|
this.addEventListeners('.glossary-item', 'mouseup', this.onGlossaryMouseUp.bind(this));
|
||||||
this.addEventListeners('.glossary-item', 'mousedown', this.onGlossaryMousedown.bind(this));
|
this.addEventListeners('.glossary-item', 'mousedown', this.onGlossaryMouseDown.bind(this));
|
||||||
this.addEventListeners('.glossary-item', 'mousemove', this.onGlossaryMouseMove.bind(this));
|
this.addEventListeners('.glossary-item', 'mousemove', this.onGlossaryMouseMove.bind(this));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user