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

react-container-dimensions

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-container-dimensions - npm Package Compare versions

Comparing version 1.3.0 to 1.3.1

124

lib/index.js
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
value: true
});

@@ -36,75 +36,77 @@

var ContainerDimensions = function (_Component) {
_inherits(ContainerDimensions, _Component);
_inherits(ContainerDimensions, _Component);
_createClass(ContainerDimensions, null, [{
key: 'getDomNodeDimensions',
value: function getDomNodeDimensions(node) {
var _node$getBoundingClie = node.getBoundingClientRect();
_createClass(ContainerDimensions, null, [{
key: 'getDomNodeDimensions',
value: function getDomNodeDimensions(node) {
var _node$getBoundingClie = node.getBoundingClientRect(),
top = _node$getBoundingClie.top,
right = _node$getBoundingClie.right,
bottom = _node$getBoundingClie.bottom,
left = _node$getBoundingClie.left,
width = _node$getBoundingClie.width,
height = _node$getBoundingClie.height;
var top = _node$getBoundingClie.top;
var right = _node$getBoundingClie.right;
var bottom = _node$getBoundingClie.bottom;
var left = _node$getBoundingClie.left;
var width = _node$getBoundingClie.width;
var height = _node$getBoundingClie.height;
return { top: top, right: right, bottom: bottom, left: left, width: width, height: height };
}
}]);
return { top: top, right: right, bottom: bottom, left: left, width: width, height: height };
}
}]);
function ContainerDimensions() {
_classCallCheck(this, ContainerDimensions);
function ContainerDimensions() {
_classCallCheck(this, ContainerDimensions);
var _this = _possibleConstructorReturn(this, (ContainerDimensions.__proto__ || Object.getPrototypeOf(ContainerDimensions)).call(this));
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(ContainerDimensions).call(this));
_this.state = {
initiated: false
};
_this.onResize = _this.onResize.bind(_this);
return _this;
}
_this.state = {
initiated: false
};
_this.onResize = _this.onResize.bind(_this);
return _this;
_createClass(ContainerDimensions, [{
key: 'componentDidMount',
value: function componentDidMount() {
this.parentNode = _reactDom2.default.findDOMNode(this).parentNode;
this.elementResizeDetector = (0, _elementResizeDetector2.default)({
strategy: 'scroll',
callOnAdd: false
});
this.elementResizeDetector.listenTo(this.parentNode, this.onResize);
this.onResize();
}
}, {
key: 'componentWillUnmount',
value: function componentWillUnmount() {
this.elementResizeDetector.uninstall(this.parentNode);
}
}, {
key: 'onResize',
value: function onResize() {
var clientRect = ContainerDimensions.getDomNodeDimensions(this.parentNode);
this.setState(_extends({
initiated: true
}, clientRect));
}
}, {
key: 'render',
value: function render() {
(0, _invariant2.default)(this.props.children, 'Expected children to be one of function or React.Element');
_createClass(ContainerDimensions, [{
key: 'componentDidMount',
value: function componentDidMount() {
this.parentNode = _reactDom2.default.findDOMNode(this).parentNode;
this.elementResizeDetector = (0, _elementResizeDetector2.default)({ strategy: 'scroll' });
this.elementResizeDetector.listenTo(this.parentNode, this.onResize);
this.onResize();
}
}, {
key: 'componentWillUnmount',
value: function componentWillUnmount() {
this.elementResizeDetector.removeListener(this.parentNode, this.onResize);
}
}, {
key: 'onResize',
value: function onResize() {
var clientRect = ContainerDimensions.getDomNodeDimensions(this.parentNode);
this.setState(_extends({
initiated: true
}, clientRect));
}
}, {
key: 'render',
value: function render() {
(0, _invariant2.default)(this.props.children, 'Expected children to be one of function or React.Element');
if (!this.state.initiated) {
return _react2.default.createElement('div', null);
}
if (typeof this.props.children === 'function') {
var renderedChildren = this.props.children(this.state);
return renderedChildren && _react.Children.only(renderedChildren);
}
return _react.Children.only(_react2.default.cloneElement(this.props.children, this.state));
}
}]);
if (!this.state.initiated) {
return _react2.default.createElement('div', null);
}
if (typeof this.props.children === 'function') {
var renderedChildren = this.props.children(this.state);
return renderedChildren && _react.Children.only(renderedChildren);
}
return _react.Children.only(_react2.default.cloneElement(this.props.children, this.state));
}
}]);
return ContainerDimensions;
return ContainerDimensions;
}(_react.Component);
ContainerDimensions.propTypes = {
children: _react.PropTypes.oneOfType([_react.PropTypes.element, _react.PropTypes.func]).isRequired
children: _react.PropTypes.oneOfType([_react.PropTypes.element, _react.PropTypes.func]).isRequired
};
exports.default = ContainerDimensions;
{
"name": "react-container-dimensions",
"version": "1.3.0",
"version": "1.3.1",
"description": "Wrapper component that detects element resize and passes new dimensions down the tree. Based on [element-resize-detector](https://github.com/wnr/element-resize-detector)",

@@ -10,17 +10,21 @@ "main": "lib/index.js",

"lint": "eslint ./src",
"lint:fix": "eslint --fix ./src",
"prepublish": "npm run lint && npm run clean && npm run build",
"test": "mocha --compilers js:babel-core/register --require testSetup.js --recursive ./tests/*.js",
"test:watch": "npm test -- --watch",
"eslint-staged": "eslint-staged",
"lint-staged": "lint-staged",
"deps": "npm-check -s",
"deps:update": "npm-check -u",
"release": "npmpub"
"release": "npmpub",
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
},
"pre-commit": [
"eslint-staged"
],
"lint-staged": {
"*.js": [
"eslint --fix",
"git add"
]
},
"pre-commit": "lint-staged",
"repository": {
"type": "git",
"url": "git+https://github.com/okonet/react-container-dimensions.git"
"url": "https://github.com/okonet/react-container-dimensions.git"
},

@@ -45,3 +49,3 @@ "files": [

"author": "Andrey Okonetchnikov <andrey@okonet.ru>",
"license": "ISC",
"license": "MIT",
"bugs": {

@@ -52,4 +56,4 @@ "url": "https://github.com/okonet/react-container-dimensions/issues"

"dependencies": {
"element-resize-detector": "^1.1.5",
"invariant": "^2.2.1"
"element-resize-detector": "^1.1.10",
"invariant": "^2.2.2"
},

@@ -61,25 +65,25 @@ "peerDependencies": {

"devDependencies": {
"babel": "^6.5.2",
"babel-cli": "^6.6.5",
"babel-preset-es2015": "^6.6.0",
"babel-preset-react": "^6.5.0",
"babel-preset-stage-1": "^6.5.0",
"babel": "^6.23.0",
"babel-cli": "^6.23.0",
"babel-preset-es2015": "^6.22.0",
"babel-preset-react": "^6.23.0",
"babel-preset-stage-1": "^6.22.0",
"chai": "^3.5.0",
"chai-enzyme": "^0.4.1",
"enzyme": "^2.2.0",
"eslint": "^2.5.3",
"eslint-config-wildbit": "^2.0.0",
"eslint-plugin-import": "^1.4.0",
"jsdom": "^8.4.0",
"lint-staged": "^0.1.1",
"mocha": "^2.4.5",
"chai-enzyme": "^0.6.1",
"enzyme": "^2.7.1",
"eslint": "^3.11.0",
"eslint-config-okonet": "^1.2.3",
"jsdom": "^9.11.0",
"lint-staged": "^3.2.1",
"mocha": "^3.2.0",
"npm-check": "^5.2.2",
"npmpub": "^3.1.0",
"pre-commit": "^1.1.2",
"react": "^0.14.8",
"react-addons-test-utils": "^0.14.8",
"react-dom": "^0.14.8",
"react": "^15.4.1",
"react-addons-test-utils": "^15.4.1",
"react-dom": "^15.4.1",
"rimraf": "^2.5.3",
"sinon": "^1.17.3"
"sinon": "^1.17.7",
"semantic-release": "^6.3.2"
}
}
}

@@ -1,2 +0,2 @@

# react-container-dimensions [![Build Status](https://travis-ci.org/okonet/react-container-dimensions.svg?branch=master)](https://travis-ci.org/okonet/react-container-dimensions)
# react-container-dimensions [![Build Status](https://travis-ci.org/okonet/react-container-dimensions.svg?branch=master)](https://travis-ci.org/okonet/react-container-dimensions) [![npm version](https://badge.fury.io/js/react-container-dimensions.svg)](https://badge.fury.io/js/react-container-dimensions)
Wrapper component that detects parent (container) element resize and passes new dimensions down the

@@ -3,0 +3,0 @@ tree. Based on [element-resize-detector]

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