mirror of
https://github.com/zen-browser/components.git
synced 2025-07-07 21:09:58 +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() {
|
async initiateGlance() {
|
||||||
this.mouseIsDown = false;
|
this.mouseIsDown = false;
|
||||||
const activationMethod = await this.getActivationMethod();
|
const activationMethod = await this.getActivationMethod();
|
||||||
if (activationMethod === 'hover') {
|
if (activationMethod === 'mantain') {
|
||||||
this.contentWindow.addEventListener('mousedown', this.mouseDownListener);
|
this.contentWindow.addEventListener('mousedown', this.mouseDownListener);
|
||||||
this.contentWindow.addEventListener('mouseup', this.mouseUpListener);
|
this.contentWindow.addEventListener('mouseup', this.mouseUpListener);
|
||||||
|
|
||||||
|
@ -67,18 +67,26 @@ export class ZenGlanceChild extends JSWindowActorChild {
|
||||||
}
|
}
|
||||||
|
|
||||||
handleMouseUp(event) {
|
handleMouseUp(event) {
|
||||||
this.mouseIsDown = false;
|
if (this.hasClicked) {
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
this.hasClicked = false;
|
||||||
|
}
|
||||||
|
this.mouseIsDown = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
async handleMouseDown(event) {
|
async handleMouseDown(event) {
|
||||||
if (event.target.tagName !== 'A') {
|
const target = event.target.closest('A');
|
||||||
|
console.log('target', target);
|
||||||
|
if (!target) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.mouseIsDown = true;
|
this.mouseIsDown = target;
|
||||||
const hoverActivationDelay = await this.getHoverActivationDelay();
|
const hoverActivationDelay = await this.getHoverActivationDelay();
|
||||||
setTimeout(() => {
|
this.contentWindow.setTimeout(() => {
|
||||||
if (this.mouseIsDown) {
|
if (this.mouseIsDown === target) {
|
||||||
this.openGlance(event.target);
|
this.hasClicked = true;
|
||||||
|
this.openGlance(target);
|
||||||
}
|
}
|
||||||
}, hoverActivationDelay);
|
}, hoverActivationDelay);
|
||||||
}
|
}
|
||||||
|
@ -94,7 +102,7 @@ export class ZenGlanceChild extends JSWindowActorChild {
|
||||||
return;
|
return;
|
||||||
} else if (activationMethod === 'shift' && !event.shiftKey) {
|
} else if (activationMethod === 'shift' && !event.shiftKey) {
|
||||||
return;
|
return;
|
||||||
} else if (activationMethod === 'hover' || typeof activationMethod === 'undefined') {
|
} else if (activationMethod === 'mantain' || typeof activationMethod === 'undefined') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// get closest A element
|
// get closest A element
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue