aboutsummaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/operations.js3
-rw-r--r--src/shared/settings/default.js1
-rw-r--r--src/shared/utils/dom.js24
3 files changed, 27 insertions, 1 deletions
diff --git a/src/shared/operations.js b/src/shared/operations.js
index 4172f8b..008e9eb 100644
--- a/src/shared/operations.js
+++ b/src/shared/operations.js
@@ -31,6 +31,9 @@ export default {
NAVIGATE_PARENT: 'navigate.parent',
NAVIGATE_ROOT: 'navigate.root',
+ // Focus
+ FOCUS_INPUT: 'focus.input',
+
// Tabs
TAB_CLOSE: 'tabs.close',
TAB_CLOSE_FORCE: 'tabs.close.force',
diff --git a/src/shared/settings/default.js b/src/shared/settings/default.js
index c85a079..3c4dcac 100644
--- a/src/shared/settings/default.js
+++ b/src/shared/settings/default.js
@@ -45,6 +45,7 @@ export default {
"]]": { "type": "navigate.link.next" },
"gu": { "type": "navigate.parent" },
"gU": { "type": "navigate.root" },
+ "gi": { "type": "focus.input" },
"y": { "type": "urls.yank" },
"p": { "type": "urls.paste", "newTab": false },
"P": { "type": "urls.paste", "newTab": true },
diff --git a/src/shared/utils/dom.js b/src/shared/utils/dom.js
index d4fd68a..f138c33 100644
--- a/src/shared/utils/dom.js
+++ b/src/shared/utils/dom.js
@@ -81,4 +81,26 @@ const viewportRect = (e) => {
};
};
-export { isContentEditable, viewportRect };
+const isVisible = (element) => {
+ let rect = element.getBoundingClientRect();
+ if (rect.width === 0 || rect.height === 0) {
+ return false;
+ }
+ if (rect.right < 0 && rect.bottom < 0) {
+ return false;
+ }
+ if (window.innerWidth < rect.left && window.innerHeight < rect.top) {
+ return false;
+ }
+ if (element.nodeName === 'INPUT' && element.type.toLowerCase() === 'hidden') {
+ return false;
+ }
+
+ let { display, visibility } = window.getComputedStyle(element);
+ if (display === 'none' || visibility === 'hidden') {
+ return false;
+ }
+ return true;
+};
+
+export { isContentEditable, viewportRect, isVisible };