Comparing version 0.1.0 to 0.2.0
@@ -6,3 +6,3 @@ /*! @link https://github.com/alexdunphy/units, @version 0.1.0, @license MIT */ | ||
else if(typeof define === 'function' && define.amd) | ||
define(factory); | ||
define([], factory); | ||
else if(typeof exports === 'object') | ||
@@ -9,0 +9,0 @@ exports["units"] = factory(); |
/*! @link https://github.com/alexdunphy/units, @version 0.1.0, @license MIT */ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):"object"==typeof exports?exports.units=t():e.units=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){e.exports=n(1)},function(e,t,n){"use strict";e.exports=n(2)},function(e,t,n){"use strict";var r=n(3),i=n(8),o={};o.conversions=r;var u=o.properties={};u.lineHeight=u.opacity=u.scale=u.scale3d=u.scaleX=u.scaleY=u.scaleZ={defaultUnit:"",defaultValue:1},u.rotate=u.rotate3d=u.rotateX=u.rotateY=u.rotateZ=u.skew=u.skewX=u.skewY={defaultUnit:"deg"},o.convert=function(e,t,n,r){var i=o.parse(t,r);return e===i.unit?i.value:o.processConversion(i.unit,e,i.value,n,r)},o.parse=function(e,t){var n,r={};return i(e)?(r.value=e,r.unit=t?o.getDefaultUnit(t):""):(n=e.toString().trim().match(/^(-?[\d+\.\-]+)([a-z]+|%)$/i),null!==n?(r.value=n[1],r.unit=n[2]):(r.unit=e,r.value=t?o.getDefaultValue(t):0)),r.value=parseFloat(r.value),r},o.getDefaultValue=function(e){return"undefined"!=typeof u[e]&&"undefined"!=typeof u[e].defaultValue?u[e].defaultValue:0},o.getDefaultUnit=function(e){return"undefined"!=typeof u[e]&&"undefined"!=typeof u[e].defaultUnit?u[e].defaultUnit:"px"},o.processConversion=function(e,t,n,r,i){var u,f=o.getConversionType(e);return"function"==typeof f[e][t]?u=f[e][t]:(u=f[f._default][t],n=f[e][f._default](n,r,i)),u(n,r,i)},o.getConversionType=function(e){var t,n=null;for(t in r)if(r.hasOwnProperty(t)&&"undefined"!=typeof r[t][e]){n=r[t];break}return n},e.exports=o},function(e,t,n){"use strict";e.exports={length:n(4),angle:n(7)}},function(e,t,n){"use strict";var r=n(5),i=n(6),o={_default:"px"};o[""]={px:function(e,t){return parseFloat(getComputedStyle(t,"").fontSize)*e}},o["%"]={px:function(e,t,n){return e*r.getRelativeElementDimension(t,n)/100}},o.ch={px:function(e,t){return e*r.ifZeroThenOne(r.getCreatedElementWidth(t,null,"0"))}},o.cm={px:function(e){return e/2.54*r.ifZeroThenOne(r.DPI)}},o.em={px:function(e,t){return e*r.getElementFontSize(t)}},o.ex={px:function(e,t){return e*r.getCreatedElementHeight(t,null,"x")}},o["in"]={px:function(e){return e*r.DPI}},o.mm={px:function(e){return e/2.54*r.ifZeroThenOne(r.DPI)/10}},o.pc={px:function(e){return e*(r.DPI/72)*12}},o.pt={px:function(e){return e*r.DPI/72}},o.px={"":function(e,t){return e/parseFloat(getComputedStyle(t,"").fontSize)},"%":function(e,t,n){return e/r.ifZeroThenOne(r.getRelativeElementDimension(t,n))*100},ch:function(e,t){return e/r.ifZeroThenOne(r.getCreatedElementWidth(t,null,"0"))},cm:function(e){return e/r.ifZeroThenOne(r.DPI)*2.54},em:function(e,t){return e/r.ifZeroThenOne(r.getElementFontSize(t))},ex:function(e,t){return e/r.ifZeroThenOne(r.getCreatedElementHeight(t,null,"x"))},"in":function(e){return e/r.ifZeroThenOne(r.DPI)},mm:function(e){return 2.54*e/r.ifZeroThenOne(r.DPI)*10},pc:function(e){return e/(r.DPI/72*12)},pt:function(e){return 72*e/r.DPI},rem:function(e){return e/r.ifZeroThenOne(r.getElementFontSize(document.documentElement))},vh:function(e){return e/r.ifZeroThenOne(i.height()/100)},vmax:function(e){return e/r.ifZeroThenOne(i.max()/100)},vmin:function(e){return e/r.ifZeroThenOne(i.min()/100)},vw:function(e){return e/r.ifZeroThenOne(i.width()/100)}},o.rem={px:function(e){return e*r.getElementFontSize(document.documentElement)}},o.vh={px:function(e){return e*(i.height()/100)}},o.vmax={px:function(e){return e*(i.max()/100)}},o.vmin={px:function(e){return e*(i.min()/100)}},o.vw={px:function(e){return e*(i.width()/100)}},e.exports=o},function(e,t){"use strict";var n={};n.getElementFontSize=function(e){return parseFloat(getComputedStyle(e,"").fontSize)},n.getCreatedElementDimensions=function(e,t,n){var r,i,o=document.createElement("div"),u=o.style;if(u.position="absolute",u.zIndex=-2147483648,u.left=0,u.top=0,u.visibility="hidden",t)for(i in t)t.hasOwnProperty(i)&&(u[i]=t[i]);return n&&(o.innerHTML=n),e.appendChild(o),r=[o.offsetWidth,o.offsetHeight],e.removeChild(o),r},n.getCreatedElementWidth=function(e,t,r){return n.getCreatedElementDimensions(e,t,r)[0]},n.getCreatedElementHeight=function(e,t,r){return n.getCreatedElementDimensions(e,t,r)[1]};var r=["perspective","translate","translate3d","translateX","translateY","translateZ","transformOrigin"],i=["height","top","translateY"],o=["absolute","fixed"];n.getRelativeElementDimension=function(e,t){var n,u,f,a=i.indexOf(t)>-1,d=r.indexOf(t)>-1,c=o.indexOf(getComputedStyle(e,"").position)>-1;return n=d?e:c?e.offsetParent:e.parentNode,u=a?n.offsetHeight:n.offsetWidth,!d&&c&&(f=getComputedStyle(n,""),u-=a?parseFloat(f.paddingTop)+parseFloat(f.paddingBottom):parseFloat(f.paddingRight)+parseFloat(f.paddingLeft)),u},n.DPI=function(){return"undefined"==typeof window?96:n.getCreatedElementWidth(document.body,{width:"1in"})}(),n.ifZeroThenOne=function(e){return 0===e?1:e},e.exports=n},function(e,t){"use strict";var n={},r=-1,i=-1;n.width=function(){return r},n.height=function(){return i},n.max=function(){return Math.max(r,i)},n.min=function(){return Math.min(r,i)},n.setDimensions=function(){"undefined"!=typeof document&&(r=document.documentElement.clientWidth,i=document.documentElement.clientHeight)},n.onWindowResize=function(){n.setDimensions()},"undefined"!=typeof window&&(window.addEventListener("resize",n.onWindowResize,!1),window.addEventListener("orientationchange",n.onWindowResize,!1),n.setDimensions()),e.exports=n},function(e,t){"use strict";var n={_default:"deg"};n.deg={grad:function(e){return e/.9},rad:function(e){return e*(Math.PI/180)},turn:function(e){return e/360}},n.grad={deg:function(e){return.9*e}},n.rad={deg:function(e){return e/(Math.PI/180)}},n.turn={deg:function(e){return 360*e}},e.exports=n},function(e,t,n){var r=function(e){return e="string"==typeof e?e.replace(/,/g,""):e,!isNaN(parseFloat(e))&&isFinite(e)&&"[object array]"!==Object.prototype.toString.call(e).toLowerCase()};"undefined"!=typeof e&&e.exports&&(t=e.exports=r),t.isNumeric=r}])}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.units=t():e.units=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){e.exports=n(1)},function(e,t,n){"use strict";e.exports=n(2)},function(e,t,n){"use strict";var r=n(3),i=n(8),o={};o.conversions=r;var u=o.properties={};u.lineHeight=u.opacity=u.scale=u.scale3d=u.scaleX=u.scaleY=u.scaleZ={defaultUnit:"",defaultValue:1},u.rotate=u.rotate3d=u.rotateX=u.rotateY=u.rotateZ=u.skew=u.skewX=u.skewY={defaultUnit:"deg"},o.convert=function(e,t,n,r){var i=o.parse(t,r);return e===i.unit?i.value:o.processConversion(i.unit,e,i.value,n,r)},o.parse=function(e,t){var n,r={};return i(e)?(r.value=e,r.unit=t?o.getDefaultUnit(t):""):(n=e.toString().trim().match(/^(-?[\d+\.\-]+)([a-z]+|%)$/i),null!==n?(r.value=n[1],r.unit=n[2]):(r.unit=e,r.value=t?o.getDefaultValue(t):0)),r.value=parseFloat(r.value),r},o.getDefaultValue=function(e){return"undefined"!=typeof u[e]&&"undefined"!=typeof u[e].defaultValue?u[e].defaultValue:0},o.getDefaultUnit=function(e){return"undefined"!=typeof u[e]&&"undefined"!=typeof u[e].defaultUnit?u[e].defaultUnit:"px"},o.processConversion=function(e,t,n,r,i){var u,f=o.getConversionType(e);return"function"==typeof f[e][t]?u=f[e][t]:(u=f[f._default][t],n=f[e][f._default](n,r,i)),u(n,r,i)},o.getConversionType=function(e){var t,n=null;for(t in r)if(r.hasOwnProperty(t)&&"undefined"!=typeof r[t][e]){n=r[t];break}return n},e.exports=o},function(e,t,n){"use strict";e.exports={length:n(4),angle:n(7)}},function(e,t,n){"use strict";var r=n(5),i=n(6),o={_default:"px"};o[""]={px:function(e,t){return parseFloat(getComputedStyle(t,"").fontSize)*e}},o["%"]={px:function(e,t,n){return e*r.getRelativeElementDimension(t,n)/100}},o.ch={px:function(e,t){return e*r.ifZeroThenOne(r.getCreatedElementWidth(t,null,"0"))}},o.cm={px:function(e){return e/2.54*r.ifZeroThenOne(r.DPI)}},o.em={px:function(e,t){return e*r.getElementFontSize(t)}},o.ex={px:function(e,t){return e*r.getCreatedElementHeight(t,null,"x")}},o["in"]={px:function(e){return e*r.DPI}},o.mm={px:function(e){return e/2.54*r.ifZeroThenOne(r.DPI)/10}},o.pc={px:function(e){return e*(r.DPI/72*12)}},o.pt={px:function(e){return e*r.DPI/72}},o.px={"":function(e,t){return e/parseFloat(getComputedStyle(t,"").fontSize)},"%":function(e,t,n){return e/r.ifZeroThenOne(r.getRelativeElementDimension(t,n))*100},ch:function(e,t){return e/r.ifZeroThenOne(r.getCreatedElementWidth(t,null,"0"))},cm:function(e){return e/r.ifZeroThenOne(r.DPI)*2.54},em:function(e,t){return e/r.ifZeroThenOne(r.getElementFontSize(t))},ex:function(e,t){return e/r.ifZeroThenOne(r.getCreatedElementHeight(t,null,"x"))},"in":function(e){return e/r.ifZeroThenOne(r.DPI)},mm:function(e){return 2.54*e/r.ifZeroThenOne(r.DPI)*10},pc:function(e){return e/(r.DPI/72*12)},pt:function(e){return 72*e/r.DPI},rem:function(e){return e/r.ifZeroThenOne(r.getElementFontSize(document.documentElement))},vh:function(e){return e/r.ifZeroThenOne(i.height()/100)},vmax:function(e){return e/r.ifZeroThenOne(i.max()/100)},vmin:function(e){return e/r.ifZeroThenOne(i.min()/100)},vw:function(e){return e/r.ifZeroThenOne(i.width()/100)}},o.rem={px:function(e){return e*r.getElementFontSize(document.documentElement)}},o.vh={px:function(e){return e*(i.height()/100)}},o.vmax={px:function(e){return e*(i.max()/100)}},o.vmin={px:function(e){return e*(i.min()/100)}},o.vw={px:function(e){return e*(i.width()/100)}},e.exports=o},function(e,t){"use strict";var n={};n.getElementFontSize=function(e){return parseFloat(getComputedStyle(e,"").fontSize)},n.getCreatedElementDimensions=function(e,t,n){var r,i,o=document.createElement("div"),u=o.style;if(u.position="absolute",u.zIndex=-2147483648,u.left=0,u.top=0,u.visibility="hidden",t)for(i in t)t.hasOwnProperty(i)&&(u[i]=t[i]);return n&&(o.innerHTML=n),e.appendChild(o),r=[o.offsetWidth,o.offsetHeight],e.removeChild(o),r},n.getCreatedElementWidth=function(e,t,r){return n.getCreatedElementDimensions(e,t,r)[0]},n.getCreatedElementHeight=function(e,t,r){return n.getCreatedElementDimensions(e,t,r)[1]};var r=["perspective","translate","translate3d","translateX","translateY","translateZ","transformOrigin"],i=["height","top","translateY"],o=["absolute","fixed"];n.getRelativeElementDimension=function(e,t){var n,u,f,a=i.indexOf(t)>-1,d=r.indexOf(t)>-1,c=o.indexOf(getComputedStyle(e,"").position)>-1;return n=d?e:c?e.offsetParent:e.parentNode,u=a?n.offsetHeight:n.offsetWidth,!d&&c&&(f=getComputedStyle(n,""),u-=a?parseFloat(f.paddingTop)+parseFloat(f.paddingBottom):parseFloat(f.paddingRight)+parseFloat(f.paddingLeft)),u},n.DPI=function(){return"undefined"==typeof window?96:n.getCreatedElementWidth(document.body,{width:"1in"})}(),n.ifZeroThenOne=function(e){return 0===e?1:e},e.exports=n},function(e,t){"use strict";var n={},r=-1,i=-1;n.width=function(){return r},n.height=function(){return i},n.max=function(){return Math.max(r,i)},n.min=function(){return Math.min(r,i)},n.setDimensions=function(){"undefined"!=typeof document&&(r=document.documentElement.clientWidth,i=document.documentElement.clientHeight)},n.onWindowResize=function(){n.setDimensions()},"undefined"!=typeof window&&(window.addEventListener("resize",n.onWindowResize,!1),window.addEventListener("orientationchange",n.onWindowResize,!1),n.setDimensions()),e.exports=n},function(e,t){"use strict";var n={_default:"deg"};n.deg={grad:function(e){return e/.9},rad:function(e){return e*(Math.PI/180)},turn:function(e){return e/360}},n.grad={deg:function(e){return.9*e}},n.rad={deg:function(e){return e/(Math.PI/180)}},n.turn={deg:function(e){return 360*e}},e.exports=n},function(e,t,n){var r=function(e){return e="string"==typeof e?e.replace(/,/g,""):e,!isNaN(parseFloat(e))&&isFinite(e)&&"[object array]"!==Object.prototype.toString.call(e).toLowerCase()};"undefined"!=typeof e&&e.exports&&(t=e.exports=r),t.isNumeric=r}])}); |
{ | ||
"name": "units-css", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "Parse length and angle CSS values and convert between units", | ||
@@ -27,3 +27,2 @@ "author": "Alex Dunphy <alexanderdunphy@gmail.com>", | ||
"gulp-header": "^1.7.1", | ||
"gulp-if": "^1.2.5", | ||
"gulp-notify": "^2.2.0", | ||
@@ -42,3 +41,3 @@ "gulp-rename": "^1.2.2", | ||
"lodash": "^3.10.1", | ||
"mocha": "^2.2.5", | ||
"mocha": "^2.3.0", | ||
"phantomjs": "^1.9.18", | ||
@@ -50,4 +49,17 @@ "run-sequence": "^1.1.2", | ||
"isnumeric": "^0.2.0", | ||
"viewport-dimensions": "^0.1.0" | ||
} | ||
"viewport-dimensions": "^0.2.0" | ||
}, | ||
"keywords": [ | ||
"unit", | ||
"units", | ||
"value", | ||
"values", | ||
"property", | ||
"properties", | ||
"rule", | ||
"rules", | ||
"css", | ||
"parse", | ||
"convert" | ||
] | ||
} |
@@ -60,2 +60,5 @@ [![Travis CI status](https://img.shields.io/travis/alexdunphy/units.svg)](https://travis-ci.org/alexdunphy/units) | ||
##### Transforms | ||
`transform` should not be passed directly as the property name - instead specify a transform keyword (e.g. `rotate`). | ||
### #convert(to, value, element, property) | ||
@@ -83,3 +86,4 @@ | ||
**N.B.** `transform` should not be passed directly as the property name - instead specify a transform keyword (e.g. `rotate`). | ||
##### Transforms | ||
`transform` should not be passed directly as the property name - instead specify a transform keyword (e.g. `rotate`). | ||
@@ -86,0 +90,0 @@ ### #getDefaultValue(property) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
57096
23
147
+ Addedviewport-dimensions@0.2.0(transitive)
- Removedviewport-dimensions@0.1.0(transitive)
Updatedviewport-dimensions@^0.2.0