commit
1f57547c0a
8 changed files with 48 additions and 22 deletions
|
@ -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',
|
||||
|
|
|
@ -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 },
|
||||
|
|
|
@ -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 };
|
||||
|
|
Reference in a new issue