mirror of
https://github.com/zen-browser/components.git
synced 2025-07-07 17:15:31 +02:00
Refactor ZenGlanceChild.sys.mjs to use 'mantain' as the activation method instead of 'hover'
This commit is contained in:
parent
8cfb95a3ac
commit
893eead718
1 changed files with 16 additions and 8 deletions
|
@ -38,7 +38,7 @@ export class ZenGlanceChild extends JSWindowActorChild {
|
|||
async initiateGlance() {
|
||||
this.mouseIsDown = false;
|
||||
const activationMethod = await this.getActivationMethod();
|
||||
if (activationMethod === 'hover') {
|
||||
if (activationMethod === 'mantain') {
|
||||
this.contentWindow.addEventListener('mousedown', this.mouseDownListener);
|
||||
this.contentWindow.addEventListener('mouseup', this.mouseUpListener);
|
||||
|
||||
|
@ -67,18 +67,26 @@ export class ZenGlanceChild extends JSWindowActorChild {
|
|||
}
|
||||
|
||||
handleMouseUp(event) {
|
||||
this.mouseIsDown = false;
|
||||
if (this.hasClicked) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
this.hasClicked = false;
|
||||
}
|
||||
this.mouseIsDown = null;
|
||||
}
|
||||
|
||||
async handleMouseDown(event) {
|
||||
if (event.target.tagName !== 'A') {
|
||||
const target = event.target.closest('A');
|
||||
console.log('target', target);
|
||||
if (!target) {
|
||||
return;
|
||||
}
|
||||
this.mouseIsDown = true;
|
||||
this.mouseIsDown = target;
|
||||
const hoverActivationDelay = await this.getHoverActivationDelay();
|
||||
setTimeout(() => {
|
||||
if (this.mouseIsDown) {
|
||||
this.openGlance(event.target);
|
||||
this.contentWindow.setTimeout(() => {
|
||||
if (this.mouseIsDown === target) {
|
||||
this.hasClicked = true;
|
||||
this.openGlance(target);
|
||||
}
|
||||
}, hoverActivationDelay);
|
||||
}
|
||||
|
@ -94,7 +102,7 @@ export class ZenGlanceChild extends JSWindowActorChild {
|
|||
return;
|
||||
} else if (activationMethod === 'shift' && !event.shiftKey) {
|
||||
return;
|
||||
} else if (activationMethod === 'hover' || typeof activationMethod === 'undefined') {
|
||||
} else if (activationMethod === 'mantain' || typeof activationMethod === 'undefined') {
|
||||
return;
|
||||
}
|
||||
// get closest A element
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue