get-node-dimensions
Advanced tools
Comparing version 0.1.1 to 1.0.0
## CHANGELOG | ||
### 1.0.0 | ||
Use original node to get style information because clone returns nothing | ||
Account for clone display, width, and height properties better | ||
Remove bower in favor of using NPMCDN | ||
### 0.1.1 | ||
@@ -3,0 +10,0 @@ Fix build for NPMCDN |
@@ -111,3 +111,3 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
var clone = node.cloneNode(true); | ||
var style = getComputedStyle(clone); | ||
var style = getComputedStyle(node); | ||
var rect = {}; | ||
@@ -126,7 +126,9 @@ | ||
// set props to get a true dimension calculation | ||
clone.style.display = options.display || style.getPropertyValue('display'); | ||
if (style.getPropertyValue('width') !== '') { | ||
if (style.getPropertyValue('display') === 'none') { | ||
clone.style.display = options.display || 'block'; | ||
} | ||
if (!parseInt(style.getPropertyValue('width'))) { | ||
clone.style.width = 'auto'; | ||
} | ||
if (style.getPropertyValue('height') !== '') { | ||
if (!parseInt(style.getPropertyValue('height'))) { | ||
clone.style.height = 'auto'; | ||
@@ -133,0 +135,0 @@ } |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.getNodeDimensions=t():e.getNodeDimensions=t()}(this,function(){return function(e){function t(i){if(o[i])return o[i].exports;var n=o[i]={exports:{},id:i,loaded:!1};return e[i].call(n.exports,n,n.exports,t),n.loaded=!0,n.exports}var o={};return t.m=e,t.c=o,t.p="dist/",t(0)}([function(e,t,o){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}function n(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],o=e.getBoundingClientRect(),i=o.width,n=o.height;return i&&n&&!t.clone||(o=(0,d["default"])(e,t),i=o.width,n=o.height),{width:i,height:n,top:o.top,right:o.right,bottom:o.bottom,left:o.left}}Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=n;var r=o(1),d=i(r);e.exports=t["default"]},function(e,t){"use strict";function o(e,t){var o=e.parentNode,i=document.createElement("div"),n=e.cloneNode(!0),r=getComputedStyle(n),d={};return i.style.height=0,i.style.overflow="hidden",n.setAttribute("id",""),n.setAttribute("name",""),n.style.display=t.display||r.getPropertyValue("display"),""!==r.getPropertyValue("width")&&(n.style.width="auto"),""!==r.getPropertyValue("height")&&(n.style.height="auto"),i.appendChild(n),o.appendChild(i),d=n.getBoundingClientRect(),o.removeChild(i),d}Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=o,e.exports=t["default"]}])}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.getNodeDimensions=t():e.getNodeDimensions=t()}(this,function(){return function(e){function t(n){if(o[n])return o[n].exports;var i=o[n]={exports:{},id:n,loaded:!1};return e[n].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var o={};return t.m=e,t.c=o,t.p="dist/",t(0)}([function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function i(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],o=e.getBoundingClientRect(),n=o.width,i=o.height;return n&&i&&!t.clone||(o=(0,d["default"])(e,t),n=o.width,i=o.height),{width:n,height:i,top:o.top,right:o.right,bottom:o.bottom,left:o.left}}Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=i;var r=o(1),d=n(r);e.exports=t["default"]},function(e,t){"use strict";function o(e,t){var o=e.parentNode,n=document.createElement("div"),i=e.cloneNode(!0),r=getComputedStyle(e),d={};return n.style.height=0,n.style.overflow="hidden",i.setAttribute("id",""),i.setAttribute("name",""),"none"===r.getPropertyValue("display")&&(i.style.display=t.display||"block"),parseInt(r.getPropertyValue("width"))||(i.style.width="auto"),parseInt(r.getPropertyValue("height"))||(i.style.height="auto"),n.appendChild(i),o.appendChild(n),d=i.getBoundingClientRect(),o.removeChild(n),d}Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=o,e.exports=t["default"]}])}); |
@@ -13,3 +13,3 @@ 'use strict'; | ||
var clone = node.cloneNode(true); | ||
var style = getComputedStyle(clone); | ||
var style = getComputedStyle(node); | ||
var rect = {}; | ||
@@ -28,7 +28,9 @@ | ||
// set props to get a true dimension calculation | ||
clone.style.display = options.display || style.getPropertyValue('display'); | ||
if (style.getPropertyValue('width') !== '') { | ||
if (style.getPropertyValue('display') === 'none') { | ||
clone.style.display = options.display || 'block'; | ||
} | ||
if (!parseInt(style.getPropertyValue('width'))) { | ||
clone.style.width = 'auto'; | ||
} | ||
if (style.getPropertyValue('height') !== '') { | ||
if (!parseInt(style.getPropertyValue('height'))) { | ||
clone.style.height = 'auto'; | ||
@@ -35,0 +37,0 @@ } |
{ | ||
"name": "get-node-dimensions", | ||
"version": "0.1.1", | ||
"version": "1.0.0", | ||
"description": "Get accurate element dimensions, even if it's hidden!", | ||
@@ -5,0 +5,0 @@ "main": "lib/get-node-dimensions.js", |
@@ -7,3 +7,3 @@ ## get-node-dimensions | ||
## Usage | ||
## Install | ||
@@ -14,2 +14,7 @@ `npm install get-node-dimensions --save` | ||
```html | ||
<script src="https://unpkg.com/get-node-dimensions/dist/get-node-dimensions.js"></script> | ||
(UMD library exposed as `getNodeDimensions`) | ||
``` | ||
### Example | ||
@@ -16,0 +21,0 @@ |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
12122
184
0
26
0