Skip to content

Instantly share code, notes, and snippets.

View wKich's full-sized avatar
:octocat:
Githubing

Dmitriy Lazarev wKich

:octocat:
Githubing
View GitHub Profile
@wKich
wKich / toPx.js
Created September 28, 2016 12:18
convert CSS units to pixels
// imported from https://github.com/heygrady/Units
let preCalculated = false;
let computedValueBug = false;
const defaultView = document.defaultView;
const getComputedStyle = defaultView && defaultView.getComputedStyle;
const runit = /^(-?[\d+\.\-]+)([a-z]+|%)$/i;
const convert = {
mm2px: 1/25.4,