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

get-node-dimensions

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

get-node-dimensions - npm Package Compare versions

Comparing version 0.1.1 to 1.0.0

7

CHANGELOG.md
## 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

10

dist/get-node-dimensions.js

@@ -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 @@ }

2

dist/get-node-dimensions.min.js

@@ -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 @@

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