rc-resize-observer
Advanced tools
Comparing version 0.1.3 to 0.2.0
import * as React from 'react'; | ||
import ResizeObserver from 'resize-observer-polyfill'; | ||
interface ResizeObserverProps { | ||
export interface ResizeObserverProps { | ||
children: React.ReactNode; | ||
@@ -10,2 +10,4 @@ disabled?: boolean; | ||
height: number; | ||
offsetWidth: number; | ||
offsetHeight: number; | ||
}) => void; | ||
@@ -12,0 +14,0 @@ } |
@@ -5,2 +5,8 @@ "use strict"; | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -54,4 +60,2 @@ | ||
var util_1 = require("./util"); | ||
var INTERNAL_PREFIX_KEY = 'rc-observer-key'; // Still need to be compatible with React 15, we use class component here | ||
@@ -85,2 +89,5 @@ | ||
height = _target$getBoundingCl.height; | ||
var offsetWidth = target.offsetWidth, | ||
offsetHeight = target.offsetHeight; | ||
/** | ||
@@ -92,3 +99,2 @@ * Resize observer trigger when content size changed. | ||
var fixedWidth = Math.floor(width); | ||
@@ -106,3 +112,6 @@ var fixedHeight = Math.floor(height); | ||
if (onResize) { | ||
onResize(size); | ||
onResize(_objectSpread({}, size, { | ||
offsetWidth: offsetWidth, | ||
offsetHeight: offsetHeight | ||
})); | ||
} | ||
@@ -181,3 +190,3 @@ } | ||
if (React.isValidElement(childNode) && util_1.supportRef(childNode)) { | ||
if (React.isValidElement(childNode) && ref_1.supportRef(childNode)) { | ||
var ref = childNode.ref; | ||
@@ -184,0 +193,0 @@ childNodes[0] = React.cloneElement(childNode, { |
import * as React from 'react'; | ||
import ResizeObserver from 'resize-observer-polyfill'; | ||
interface ResizeObserverProps { | ||
export interface ResizeObserverProps { | ||
children: React.ReactNode; | ||
@@ -10,2 +10,4 @@ disabled?: boolean; | ||
height: number; | ||
offsetWidth: number; | ||
offsetHeight: number; | ||
}) => void; | ||
@@ -12,0 +14,0 @@ } |
@@ -5,2 +5,8 @@ "use strict"; | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -54,4 +60,2 @@ | ||
var util_1 = require("./util"); | ||
var INTERNAL_PREFIX_KEY = 'rc-observer-key'; // Still need to be compatible with React 15, we use class component here | ||
@@ -85,2 +89,5 @@ | ||
height = _target$getBoundingCl.height; | ||
var offsetWidth = target.offsetWidth, | ||
offsetHeight = target.offsetHeight; | ||
/** | ||
@@ -92,3 +99,2 @@ * Resize observer trigger when content size changed. | ||
var fixedWidth = Math.floor(width); | ||
@@ -106,3 +112,6 @@ var fixedHeight = Math.floor(height); | ||
if (onResize) { | ||
onResize(size); | ||
onResize(_objectSpread({}, size, { | ||
offsetWidth: offsetWidth, | ||
offsetHeight: offsetHeight | ||
})); | ||
} | ||
@@ -181,3 +190,3 @@ } | ||
if (React.isValidElement(childNode) && util_1.supportRef(childNode)) { | ||
if (React.isValidElement(childNode) && ref_1.supportRef(childNode)) { | ||
var ref = childNode.ref; | ||
@@ -184,0 +193,0 @@ childNodes[0] = React.cloneElement(childNode, { |
{ | ||
"name": "rc-resize-observer", | ||
"version": "0.1.3", | ||
"version": "0.2.0", | ||
"description": "Resize observer for React", | ||
@@ -43,3 +43,3 @@ "keywords": [ | ||
"classnames": "^2.2.1", | ||
"rc-util": "^4.13.0", | ||
"rc-util": "^4.14.0", | ||
"resize-observer-polyfill": "^1.5.1" | ||
@@ -46,0 +46,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
30101
10
516
Updatedrc-util@^4.14.0