mirror of
https://github.com/zen-browser/components.git
synced 2025-07-08 14:29:59 +02:00
Refactor ZenCompactMode to remove unused function _fixCrossedEdge and simplify _getCrossedEdge
This commit is contained in:
parent
43ed740d69
commit
5e657e93b3
1 changed files with 1 additions and 10 deletions
|
@ -210,23 +210,14 @@ var gZenCompactModeManager = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_fixCrossedEdge(edge) {
|
|
||||||
if (edge == "top") return "bottom";
|
|
||||||
if (edge == "bottom") return "top";
|
|
||||||
if (edge == "left") return "right";
|
|
||||||
if (edge == "right") return "left";
|
|
||||||
return edge;
|
|
||||||
},
|
|
||||||
|
|
||||||
_getCrossedEdge(posX, posY, element = document.documentElement, maxDistance = 5) {
|
_getCrossedEdge(posX, posY, element = document.documentElement, maxDistance = 5) {
|
||||||
const targetBox = element.getBoundingClientRect();
|
const targetBox = element.getBoundingClientRect();
|
||||||
posX = Math.max(targetBox.left, Math.min(posX, targetBox.right));
|
posX = Math.max(targetBox.left, Math.min(posX, targetBox.right));
|
||||||
posY = Math.max(targetBox.top, Math.min(posY, targetBox.bottom));
|
posY = Math.max(targetBox.top, Math.min(posY, targetBox.bottom));
|
||||||
const edge = ['top', 'bottom', 'left', 'right'].find((edge, i) => {
|
return ['top', 'bottom', 'left', 'right'].find((edge, i) => {
|
||||||
const distance = Math.abs((i < 2 ? posY : posX) - targetBox[edge]);
|
const distance = Math.abs((i < 2 ? posY : posX) - targetBox[edge]);
|
||||||
return distance <= maxDistance;
|
return distance <= maxDistance;
|
||||||
});
|
});
|
||||||
return edge;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_positionInBounds(axis = 'x', element, x, y, error = 0) {
|
_positionInBounds(axis = 'x', element, x, y, error = 0) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue