Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

spatio

Package Overview
Dependencies
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

spatio

Measure space

latest
Source
npmnpm
Version
1.1.0
Version published
Maintainers
2
Created
Source

spatio

Measure space!

Usage

// Measure 1em in pixels
spatio('10pt', 'px');  // i.e. 13.328125

// Calcucate at will!
spatio('calc(100vh - 5pt)'); // i.e. 957.328125, defaults to pixels

// Pass context element for relative space
var el = document.createElement('div');
el.style.fontSize = '24px';
document.body.appendChild(el);

spatio('1em', 'px', el); // 24

Additional units

// Line height
spatio('1lh');

// Element width and height
spatio('100ew', document.body); // 1920
spatio('100eh', document.body); // 940

// Light seconds
spatio('0.00001ls', 'px') // 335.53125

// Add custom units

// A meter beer is defined as 13 beers, so 1 beer is 100cm / 13
spatio.addUnits({
  beer: spatio('calc(100cm / 13)')
});

spatio('1beer', 'cm') // 7.694789081885856

Keywords

measure

FAQs

Package last updated on 15 Apr 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