mirror of
https://github.com/vale981/tridactyl
synced 2025-03-06 10:01:39 -05:00
dom.ts: make isVisible use parentElement clientRect if necessary
In some cases, you might need to call isVisible on a text node. These nodes don't have their own getClientRects method. It makes sense to check the parent node's getClientRects method instead since its visibility impacts its child node's.
This commit is contained in:
parent
7db70f1393
commit
2dad1c0230
1 changed files with 3 additions and 0 deletions
|
@ -217,6 +217,9 @@ export function widthMatters(style: CSSStyleDeclaration) {
|
|||
|
||||
*/
|
||||
export function isVisible(element: Element) {
|
||||
while (!(element.getClientRects instanceof Function)) {
|
||||
element = element.parentElement
|
||||
}
|
||||
const clientRect = element.getClientRects()[0]
|
||||
const computedStyle = getComputedStyle(element)
|
||||
// remove elements that are barely within the viewport, tiny, or invisible
|
||||
|
|
Loading…
Add table
Reference in a new issue