Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

get-visible-rect

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

get-visible-rect

Calculates the visible portion of the element inside the viewport

  • 0.1.2
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
62
increased by113.79%
Maintainers
1
Weekly downloads
 
Created
Source

getVisibleRect(el)

Build Status Sauce Test Status

Note: tests are failing, because they only run in PhantomJS on travis for now - enabling real browsers soon.

When the element is inside the viewport, getVisibleRect() returns:

{
	visibleHeight,
	visibleWidth,
	height,
	width,
	
	// these positions are relative to the elements top/left
	top,
	bottom,
	left,
	right
}

When element is outside the viewport, visibleHeight and visibleWidth will be 0, while top/bottom/left/right will be undefined.

My primary purpose for building this (and not using something else) is to calculate the visible percentage of the element. visibleHeight is actually bottom - top and visibleWidth is right - left. This means that the visible percentage is (visibleHeight * visibleWidth) / (height * width).

Keywords

FAQs

Package last updated on 09 Jul 2014

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc