https://github.com/thefrontside/element-is-visible
Robust algorithm for checking whether a DOM element is visible. Extracted from Selenium.
https://github.com/thefrontside/element-is-visible
Last synced: about 1 year ago
JSON representation
Robust algorithm for checking whether a DOM element is visible. Extracted from Selenium.
- Host: GitHub
- URL: https://github.com/thefrontside/element-is-visible
- Owner: thefrontside
- License: apache-2.0
- Created: 2020-09-29T14:48:30.000Z (almost 6 years ago)
- Default Branch: v1
- Last Pushed: 2022-04-29T13:58:20.000Z (about 4 years ago)
- Last Synced: 2025-03-28T11:43:26.596Z (over 1 year ago)
- Language: TypeScript
- Size: 212 KB
- Stars: 2
- Watchers: 7
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# element-is-visible
Checks whether a DOM element is visible through various heuristics, such as
checking CSS properties, sizing and overflow. The code is extracted from the
[Selenium](https://github.com/SeleniumHQ/selenium) project.
In comparison to other stand-alone libraries which perform this function, the
alogrithm implemented by Selenium is much more comprehensive and checks more
edge cases. It is still a best guess as to whether an element really is
visible, for example an element with a very low opacity is counted as visible,
even though it probably cannot be seen by an actual human.
Supports JSDOM by skipping the layout and sizing based checks.
## Usage
``` typescript
import { isVisible } from 'element-is-visible';
let element = document.querySelector('#some-element');
isVisible(element) // => true
```
## License
Apache2, see separate LICENSE and NOTICE files.