Socket
Socket
Sign inDemoInstall

predator

Package Overview
Dependencies
1
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    predator

finds the exposed portion of an element


Version published
Weekly downloads
1
Maintainers
1
Install size
9.29 MB
Created
Weekly downloads
 

Readme

Source

predator

Finds the exposed box, if there is one, of a child DOM element.

Useful if you want to check if an element is visible to the user, and how much of it.

Usage

npm install predator

Then:

var predator = require('predator');

var box = predator(someElement);

->

{
    top: offset from top of screen
    left: offset from left of screen
    right: right edge offset from left of screen
    bottom: bottom edge offset from top of screen
    height: height of the exposed region
    width: width of the exposed region
    hidden: true if the element is completely obscured from view
    original: the original result of child.getBoundingClientRect()
}

Performance

predator should be fast enough to use in a render loop, even on mobile devices.

FAQs

Last updated on 30 Apr 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc