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

cordova-plugin-screensize

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cordova-plugin-screensize

A cordova plugin to get the size of the device screen

  • 1.3.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

cordova-plugin-screensize

Platform Donate

A cordova plugin to get the size of the device screen.

Installation

cordova plugin add cordova-plugin-screensize

Supported Platforms

  • Android
  • iOS
  • OSX
  • Browser

Usage

document.addEventListener("deviceready", onDeviceReady, false);

function onDeviceReady() {
  window.plugins.screensize.get(successCallback, errorCallback);
}

function successCallback(result) {
  console.log(result);
}

The plugin returns a JSON object with the screen sizes.

Android Platform Quirks

Return values:

  • width <Number> − screen width in pixels
  • height <Number> − screen height in pixels
  • xdpi <Number> − physical pixels per inch of the screen in the X dimension
  • ydpi <Number> − physical pixels per inch of the screen in the Y dimension
  • diameter <Number> − screen diameter in inches (rounded to two decimals)
  • densityValue <Number> − density point (0.75, 1.0, 1.5, 2.0, 3.0, 4.0)
  • densityBucket <String> − density bucket (ldpi, mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi)

About density properties see this Android docs and this Device metrics page.

Known Issues

The correct device metrics setting is the manufacturer's responsibility. In a few cases the xdpi and ydpi values are wrong and the diameter calculation returns an incorrect number.

Devices with wrong settings (known so far):

  • BLU Life XL (model BLU LIFE XL, calculated diameter 8.62" vs. real diameter 5.5")
  • Samsung Galaxy SIII CDMA (model SPH-L710, calculated diameter 9.17" vs. real diameter 4.8")
  • ZTE nubia Z7 Max (model NX505J, calculated diameter 13.77" vs. real diameter 5.5")

iOS Platform Quirks

iOS has no public API for getting the device's PPI.

The plugin returns the rendered pixels of the screen.

Return values:

  • width <Number> − rendered pixel width
  • height <Number> − rendered pixel height
  • scale <Number> − render scale (1× or 2× or 3×)

OSX Platform Quirks

Return values:

  • width <Number> − screen width in pixel
  • height <Number> − screen height in pixel
  • physicalWidth <Number> − width of the display in millimeters
  • physicalHeight <Number> − height of the display in millimeters
  • dpi <Number> − physical pixels per inch of the display

Browser Platform Quirks

The plugin returns the dimensions of the viewport. You can't get the real physical dimensions or the actual DPI of the browser ( see ).

Return values:

  • width <Number> − viewport width in pixels
  • height <Number> − viewport height in pixels

Author

Peter Bakondy

LICENSE

cordova-plugin-screensize is licensed under the MIT Open Source license. For more information, see the LICENSE file in this repository.

Keywords

FAQs

Package last updated on 02 Sep 2016

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