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

zoom-level

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zoom-level

A comprehensive cross-browser package that allow you to determine page's and element's zoom level

  • 1.2.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
44K
decreased by-16.97%
Maintainers
1
Weekly downloads
 
Created
Source

zoom-level

× LIVE EXAMPLE ×

ABOUT

This plugin allows you to detect browser's and separate element's zoom level.
It is lightweight and has no dependencies!

INSTALLATION

npm install zoom-level
# or via yarn
yarn add zoom-level

USAGE

import zoomLevel from "zoom-level";

zoomLevel(); // 1;

window.addEventListener("resize", () => {
  zoomLevel(); // will return current browser's zoom level
});

Or, in case you want to detect separate element's zoom level (they can use own zoom CSS property which stacks with browser's one);

import { elementZoomLevel } from "zoom-level";

const zoomedBlock = document.createElement("div");
zoomedBlock.style.zoom = 0.5;
zoomedBlock.style.width = "150px";
zoomedBlock.style.height = "150px";
zoomedBlock.style.margin = "32px";
zoomedBlock.style.padding = "32px";
zoomedBlock.style.background = "rgba(0,0,0,.05)";
zoomedBlock.innerText = "Lorem ipusm dolor sit amet";
document.appendChild(zoomedBlock);

elementZoomLevel(zoomedBlock); // 0.5;

window.addEventListener("resize", () => {
  elementZoomLevel(zoomedBlock); // if you zoom to 200% it'll be 1
});

TESTS

Sadly i have no idea how to manage testing of this package, due to there is no known ways to control browser's zoom level.
If you know how to do it - please let me know.

Keywords

FAQs

Package last updated on 28 Jun 2019

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