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

viewporter

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

viewporter

Tools for working with all sorts of browser viewports

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
decreased by-37.5%
Maintainers
1
Weekly downloads
 
Created
Source

Viewporter

Tools for working with all sorts of browser viewports.

Tools Included

getBodyOffset

Gets the absolute offset of the body, relative to the document.

Useful for adjusting absolute positions to suit different body positions.

getElementOffset

Gets the absolute offset of an element passed to it, relative to the body.

Useful for adjusting absolute positions to suit different element positions.

getMobileScaleFactor

Like getScaleFactor, but returns 1 on devices where isDesktopSiteInMobileViewport returns false.

(We use this in Bugherd to scale our UI to fit mobile browsers when shown on desktop sites)

getScaleFactor

Gets the scaling factor of the current browser. This function doesn't distinguish between a mobile browser's viewport and a desktop browser with developer tools or a sidebar. For desktop compatibility, use getMobileScaleFactor.

getScreenWidth

Returns the normalised screen width, no matter the orientation of the device, in pixels.

getViewportCoordinates

Gets the absolute offset of the current browser viewport, relative to the body.

isDesktopSiteInMobileViewport

Tests if the screen size is greater than the inner width of the window. In these cases, it is assumed that the browser is a mobile browser.

License

MIT (see LICENSE.md)

Keywords

FAQs

Package last updated on 15 Sep 2015

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