Last active
February 17, 2022 22:04
-
-
Save ZoeBijl/2b82502951ce3907f7397b42475fc4b3 to your computer and use it in GitHub Desktop.
Check visibility of component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isHidden(element) { | |
let { length } = element.getClientRects() | |
let visibility = window.getComputedStyle(element).visibility === 'hidden' | |
let ariaHidden = element.closest('[aria-hidden]') != null | |
let inert = element.closest('[inert]') != null | |
let hidden = length === 0 || visibility === true || ariaHidden === true || inert === true | |
return hidden | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment