diff --git a/DEV_ONLY/App.js b/DEV_ONLY/App.js
index 0086de8..cb2db40 100644
--- a/DEV_ONLY/App.js
+++ b/DEV_ONLY/App.js
@@ -38,10 +38,10 @@ class Div extends Component {
children
} = this.props;
- // console.group('Div');
- // console.log('div position', this.props.position);
- // console.log('div size', this.props.size);
- // console.groupEnd();
+ console.group('Div');
+ console.log('div position', this.props.position);
+ console.log('div size', this.props.size);
+ console.groupEnd();
return (
@@ -100,10 +100,10 @@ class Main extends Component {
children
} = this.props;
- console.group('Main');
- console.log('main position', this.props.position);
- console.log('main size', this.props.size);
- console.groupEnd();
+ // console.group('Main');
+ // console.log('main position', this.props.position);
+ // console.log('main size', this.props.size);
+ // console.groupEnd();
return (
diff --git a/dist/remeasure.js b/dist/remeasure.js
index 85c73d5..8796d8b 100644
--- a/dist/remeasure.js
+++ b/dist/remeasure.js
@@ -86,9 +86,6 @@ return /******/ (function(modules) { // webpackBootstrap
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- var POSITION_PROP_DEFAULT = 'position';
- var SIZE_PROP_DEFAULT = 'size';
-
/**
* create higher-order component that injects size and position properties
* into OriginalComponent as an object under the prop name size and position
@@ -99,14 +96,14 @@ return /******/ (function(modules) { // webpackBootstrap
*/
var measure = function measure(keys, options) {
if ((0, _utils.isString)(keys)) {
- var position = POSITION_PROP_DEFAULT,
- size = SIZE_PROP_DEFAULT;
+ var position = _constants.POSITION_PROP_DEFAULT,
+ size = _constants.SIZE_PROP_DEFAULT;
if ((0, _utils.isObject)(options)) {
var _options$positionProp = options.positionProp;
- position = _options$positionProp === undefined ? POSITION_PROP_DEFAULT : _options$positionProp;
+ position = _options$positionProp === undefined ? _constants.POSITION_PROP_DEFAULT : _options$positionProp;
var _options$sizeProp = options.sizeProp;
- size = _options$sizeProp === undefined ? SIZE_PROP_DEFAULT : _options$sizeProp;
+ size = _options$sizeProp === undefined ? _constants.SIZE_PROP_DEFAULT : _options$sizeProp;
}
switch (keys) {
@@ -161,8 +158,15 @@ return /******/ (function(modules) { // webpackBootstrap
});
exports.isUndefined = exports.isString = exports.isObject = exports.isArray = exports.haveValuesChanged = exports.getValues = exports.getValidKeys = exports.getNaturalDimensionValue = exports.forEach = exports.createObjectFromKeys = exports.arraySubset = exports.arrayContains = undefined;
+ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
+
+ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // constants
+
+
var _constants = __webpack_require__(3);
+ 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; }
+
var NATURAL_REGEXP = /natural/;
/**
@@ -171,7 +175,6 @@ return /******/ (function(modules) { // webpackBootstrap
* @param {any} object
* @returns {string}
*/
- // constants
var toString = function toString(object) {
return Object.prototype.toString.call(object);
};
@@ -278,17 +281,17 @@ return /******/ (function(modules) { // webpackBootstrap
* in the source object
*
* @param {array} keys
+ * @param {function} keys.reduce
* @param {object|ClientRect} source
+ * @param {boolean} shouldAlterNaturalKeys=true
* @returns {object}
*/
var createObjectFromKeys = function createObjectFromKeys(keys, source) {
- var target = {};
+ var shouldAlterNaturalKeys = arguments.length <= 2 || arguments[2] === undefined ? true : arguments[2];
- forEach(keys, function (key) {
- target[key] = NATURAL_REGEXP.test(key) ? getNaturalDimensionValue(source, key) : source[key];
- });
-
- return target;
+ return keys.reduce(function (target, key) {
+ return _extends({}, target, _defineProperty({}, key, shouldAlterNaturalKeys ? getNaturalDimensionValue(source, key) : source[key]));
+ }, {});
};
/**
@@ -311,6 +314,56 @@ return /******/ (function(modules) { // webpackBootstrap
return validKeys;
};
+ /**
+ * get the position and size, and booleans to identify they're
+ * intended existence in state
+ *
+ * @param {array} keys
+ * @param {object} currentState
+ * @returns {{hasPosition: boolean, hasSize: boolean, position: object, size: object}}
+ */
+ var getValuesProperties = function getValuesProperties(keys, currentState) {
+ if (isArray(keys)) {
+ var _ret = function () {
+ var position = {},
+ size = {},
+ hasPosition = false,
+ hasSize = false;
+
+ forEach(keys, function (key) {
+ if (arrayContains(_constants.ALL_POSITION_KEYS, key)) {
+ position[key] = currentState[key];
+ hasPosition = true;
+ } else if (arrayContains(_constants.ALL_SIZE_KEYS, key)) {
+ size[key] = currentState[key];
+ hasSize = true;
+ }
+ });
+
+ return {
+ v: {
+ hasPosition: hasPosition,
+ hasSize: hasSize,
+ position: position,
+ size: size
+ }
+ };
+ }();
+
+ if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v;
+ }
+
+ var position = createObjectFromKeys(_constants.ALL_POSITION_KEYS, currentState, false);
+ var size = createObjectFromKeys(_constants.ALL_SIZE_KEYS, currentState, false);
+
+ return {
+ hasPosition: true,
+ hasSize: true,
+ position: position,
+ size: size
+ };
+ };
+
/**
* based on the keys passed, create an object with either position
* or size or both properties that are objects containing the respective
@@ -326,45 +379,13 @@ return /******/ (function(modules) { // webpackBootstrap
var positionProp = _ref.positionProp;
var sizeProp = _ref.sizeProp;
- var hasSize = false,
- hasPosition = false,
- size = void 0,
- position = void 0;
+ var _getValuesProperties = getValuesProperties(keys, currentState);
- if (isArray(keys)) {
- forEach(keys, function (key) {
- if (arrayContains(_constants.ALL_POSITION_KEYS, key)) {
- if (!position) {
- position = {};
- }
+ var hasSize = _getValuesProperties.hasSize;
+ var hasPosition = _getValuesProperties.hasPosition;
+ var position = _getValuesProperties.position;
+ var size = _getValuesProperties.size;
- position[key] = currentState[key];
- hasPosition = true;
- }
-
- if (arrayContains(_constants.ALL_SIZE_KEYS, key)) {
- if (!size) {
- size = {};
- }
-
- size[key] = currentState[key];
- hasSize = true;
- }
- });
- } else {
- size = {};
- position = {};
- hasSize = true;
- hasPosition = true;
-
- forEach(_constants.ALL_POSITION_KEYS, function (key) {
- position[key] = currentState[key];
- });
-
- forEach(_constants.ALL_SIZE_KEYS, function (key) {
- size[key] = currentState[key];
- });
- }
var values = {};
@@ -428,6 +449,10 @@ return /******/ (function(modules) { // webpackBootstrap
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
+ var POSITION_PROP_DEFAULT = 'position';
+ var RENDER_ON_RESIZE_DEFAULT = true;
+ var SIZE_PROP_DEFAULT = 'size';
+
var BOUNDING_CLIENT_RECT_SIZE_KEYS = ['height', 'width'];
var BOUNDING_CLIENT_RECT_POSITION_KEYS = ['bottom', 'left', 'right', 'top'];
@@ -466,6 +491,9 @@ return /******/ (function(modules) { // webpackBootstrap
exports.DOM_ELEMENT_POSITION_KEYS = DOM_ELEMENT_POSITION_KEYS;
exports.DOM_ELEMENT_SIZE_KEYS = DOM_ELEMENT_SIZE_KEYS;
exports.initialState = initialState;
+ exports.POSITION_PROP_DEFAULT = POSITION_PROP_DEFAULT;
+ exports.RENDER_ON_RESIZE_DEFAULT = RENDER_ON_RESIZE_DEFAULT;
+ exports.SIZE_PROP_DEFAULT = SIZE_PROP_DEFAULT;
/***/ },
/* 4 */
@@ -512,10 +540,6 @@ return /******/ (function(modules) { // webpackBootstrap
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; }
- var POSITION_PROP_DEFAULT = 'position';
- var RENDER_ON_RESIZE_DEFAULT = true;
- var SIZE_PROP_DEFAULT = 'size';
-
var raf = void 0;
/**
@@ -528,6 +552,23 @@ return /******/ (function(modules) { // webpackBootstrap
};
};
+ /**
+ * based on desiredKeys, build the initialState object
+ *
+ * @param {array} allKeys
+ * @param {array} desiredKeys
+ * @returns {array}
+ */
+ var reduceStateToMatchingKeys = function reduceStateToMatchingKeys(allKeys, desiredKeys) {
+ return allKeys.reduce(function (accumulatedInitialState, key) {
+ if (desiredKeys.includes(key)) {
+ return _extends({}, accumulatedInitialState, _defineProperty({}, key, 0));
+ }
+
+ return accumulatedInitialState;
+ }, {});
+ };
+
/**
* create the HOC that injects the position and size props
* into the child (assuming they have keys that are valid
@@ -541,11 +582,11 @@ return /******/ (function(modules) { // webpackBootstrap
var getHigherOrderComponent = function getHigherOrderComponent(OriginalComponent, keys) {
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
var _options$positionProp = options.positionProp;
- var positionProp = _options$positionProp === undefined ? POSITION_PROP_DEFAULT : _options$positionProp;
+ var positionProp = _options$positionProp === undefined ? _constants.POSITION_PROP_DEFAULT : _options$positionProp;
var _options$renderOnResi = options.renderOnResize;
- var renderOnResize = _options$renderOnResi === undefined ? RENDER_ON_RESIZE_DEFAULT : _options$renderOnResi;
+ var renderOnResize = _options$renderOnResi === undefined ? _constants.RENDER_ON_RESIZE_DEFAULT : _options$renderOnResi;
var _options$sizeProp = options.sizeProp;
- var sizeProp = _options$sizeProp === undefined ? SIZE_PROP_DEFAULT : _options$sizeProp;
+ var sizeProp = _options$sizeProp === undefined ? _constants.SIZE_PROP_DEFAULT : _options$sizeProp;
var propKeyNames = {
@@ -555,14 +596,7 @@ return /******/ (function(modules) { // webpackBootstrap
var boundingClientRectKeys = (0, _utils.arraySubset)(_constants.ALL_BOUNDING_CLIENT_RECT_KEYS, keys);
var domElementKeys = (0, _utils.arraySubset)(_constants.ALL_DOM_ELEMENT_KEYS, keys);
-
- var initialState = _constants.ALL_KEYS.reduce(function (accumulatedInitialState, key) {
- if (keys.includes(key)) {
- return _extends({}, accumulatedInitialState, _defineProperty({}, key, 0));
- }
-
- return accumulatedInitialState;
- }, {});
+ var initialState = reduceStateToMatchingKeys(_constants.ALL_KEYS, keys);
if (!raf) {
setRaf();
diff --git a/dist/remeasure.js.map b/dist/remeasure.js.map
index 8c7dbeb..e84a913 100644
--- a/dist/remeasure.js.map
+++ b/dist/remeasure.js.map
@@ -1 +1 @@
-{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap 10594c15bdb1827ccebc","webpack:///./src/index.js","webpack:///./src/utils.js","webpack:///./src/constants.js","webpack:///./src/getHigherOrderComponent.js","webpack:///./~/element-resize-event/index.js","webpack:///external {\"amd\":\"react\",\"commonjs\":\"react\",\"commonjs2\":\"react\",\"root\":\"React\"}","webpack:///external {\"amd\":\"react-dom\",\"commonjs\":\"react-dom\",\"commonjs2\":\"react-dom\",\"root\":\"ReactDOM\"}"],"names":["POSITION_PROP_DEFAULT","SIZE_PROP_DEFAULT","measure","keys","options","position","size","positionProp","sizeProp","validKeys","OriginalComponent","NATURAL_REGEXP","toString","object","Object","prototype","call","forEach","array","fn","length","index","isArray","isObject","isString","isUndefined","arrayContains","item","indexOf","arraySubset","array1","array2","filter","includes","getNaturalDimensionValue","source","key","replace","createObjectFromKeys","target","test","getValidKeys","keysToTestAgainst","push","getValues","currentState","hasSize","hasPosition","values","haveValuesChanged","BOUNDING_CLIENT_RECT_SIZE_KEYS","BOUNDING_CLIENT_RECT_POSITION_KEYS","ALL_BOUNDING_CLIENT_RECT_KEYS","DOM_ELEMENT_POSITION_KEYS","DOM_ELEMENT_SIZE_KEYS","ALL_DOM_ELEMENT_KEYS","ALL_POSITION_KEYS","ALL_SIZE_KEYS","ALL_KEYS","initialState","RENDER_ON_RESIZE_DEFAULT","raf","setRaf","window","requestAnimationFrame","webkitRequestAnimationFrame","mozRequestAnimationFrame","callback","setTimeout","getHigherOrderComponent","renderOnResize","propKeyNames","boundingClientRectKeys","domElementKeys","reduce","accumulatedInitialState","RemeasureComponent","state","domElement","setValues","boundingClientRect","getBoundingClientRect","setState","props"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;ACVA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,uBAAe;AACf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;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA,MAAK;AACL;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;AACA,iDAAgD,oBAAoB,QAAQ,SAAS,cAAc,aAAa,kBAAkB,sBAAsB,aAAa,YAAY;AACjL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;;;;;;;AC7FA,gD;;;;;;ACAA,gD","file":"remeasure.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"react\"), require(\"react-dom\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"Remeasure\", [\"react\", \"react-dom\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Remeasure\"] = factory(require(\"react\"), require(\"react-dom\"));\n\telse\n\t\troot[\"Remeasure\"] = factory(root[\"React\"], root[\"ReactDOM\"]);\n})(this, function(__WEBPACK_EXTERNAL_MODULE_6__, __WEBPACK_EXTERNAL_MODULE_7__) {\nreturn \n\n\n/** WEBPACK FOOTER **\n ** webpack/universalModuleDefinition\n **/"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n/** WEBPACK FOOTER **\n ** webpack/bootstrap 10594c15bdb1827ccebc\n **/","// utils\nimport {\n getValidKeys,\n isArray,\n isObject,\n isString\n} from './utils';\n\n// constants\nimport {\n ALL_KEYS,\n ALL_POSITION_KEYS,\n ALL_SIZE_KEYS\n} from './constants';\n\n// HOC\nimport getHigherOrderComponent from './getHigherOrderComponent';\n\nconst POSITION_PROP_DEFAULT = 'position';\nconst SIZE_PROP_DEFAULT = 'size';\n\n/**\n * create higher-order component that injects size and position properties\n * into OriginalComponent as an object under the prop name size and position\n *\n * @param {Component|array} keys\n * @param {object} options\n * @returns {RemeasureComponent}\n */\nconst measure = (keys, options) => {\n if (isString(keys)) {\n let position = POSITION_PROP_DEFAULT,\n size = SIZE_PROP_DEFAULT;\n\n if (isObject(options)) {\n ({\n positionProp: position = POSITION_PROP_DEFAULT,\n sizeProp: size = SIZE_PROP_DEFAULT\n } = options);\n }\n\n switch (keys) {\n case position:\n keys = ALL_POSITION_KEYS;\n break;\n\n case size:\n keys = ALL_SIZE_KEYS;\n break;\n\n default:\n keys = [keys];\n break;\n }\n }\n\n if (isArray(keys)) {\n const validKeys = getValidKeys(keys, ALL_KEYS);\n\n return (OriginalComponent) => {\n return getHigherOrderComponent(OriginalComponent, validKeys, options);\n };\n }\n\n if (isObject(keys)) {\n return (OriginalComponent) => {\n return getHigherOrderComponent(OriginalComponent, ALL_KEYS, keys);\n };\n }\n\n return getHigherOrderComponent(keys, ALL_KEYS);\n};\n\nexport default measure;\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/index.js\n **/","// constants\nimport {\n ALL_POSITION_KEYS,\n ALL_SIZE_KEYS\n} from './constants';\n\nconst NATURAL_REGEXP = /natural/;\n\n/**\n * get the toString value for the object\n *\n * @param {any} object\n * @returns {string}\n */\nconst toString = (object) => {\n return Object.prototype.toString.call(object);\n};\n\n/**\n * loop over array, executing fn\n *\n * @param {array} array\n * @param {function} fn\n */\nconst forEach = (array, fn) => {\n const length = array.length;\n\n let index = -1;\n\n while (++index < length) {\n fn(array[index], index, array);\n }\n};\n\n/**\n * determine if object is an array\n *\n * @param {any} object\n * @returns {boolean}\n */\nconst isArray = (object) => {\n return toString(object) === '[object Array]';\n};\n\n/**\n * determine if object is an object\n *\n * @param {any} object\n * @returns {boolean}\n */\nconst isObject = (object) => {\n return toString(object) === '[object Object]' && !!object;\n};\n\n/**\n * determine if object is a string\n *\n * @param {any} object\n * @returns {boolean}\n */\nconst isString = (object) => {\n return toString(object) === '[object String]';\n};\n\n/**\n * determine if object is undefined\n *\n * @param {any} object\n * @returns {boolean}\n */\nconst isUndefined = (object) => {\n return object === void 0;\n};\n\n/**\n * determine if array contains item at one of the indices\n *\n * @param {array} array\n * @param {any} item\n * @returns {boolean}\n */\nconst arrayContains = (array, item) => {\n return isArray(array) && !!~array.indexOf(item);\n};\n\n/**\n * get subset of array1 based on items existing in array2\n *\n * @param {array<*>} array1\n * @param {array<*>} array2\n * @returns {array}\n */\nconst arraySubset = (array1, array2) => {\n return array1.filter((item) => {\n return array2.includes(item);\n });\n};\n\n/**\n * For naturalHeight and naturalWidth, coalesce the values\n * with scrollHeight and scrollWIdth if the element does not\n * natively support it\n *\n * @param {HTMLElement} source\n * @param {string} key\n * @returns {number}\n */\nconst getNaturalDimensionValue = (source, key) => {\n if (isUndefined(source[key])) {\n return source[key.replace(NATURAL_REGEXP, 'scroll')];\n }\n\n return source[key];\n};\n\n/**\n * create an object based on the keys passed and their value\n * in the source object\n *\n * @param {array} keys\n * @param {object|ClientRect} source\n * @returns {object}\n */\nconst createObjectFromKeys = (keys, source) => {\n let target = {};\n\n forEach(keys, (key) => {\n target[key] = NATURAL_REGEXP.test(key) ? getNaturalDimensionValue(source, key) : source[key];\n });\n\n return target;\n};\n\n/**\n * based on their existence in keysToTestAgainst, determine which of the keys\n * passed are considered valid\n *\n * @param {array} keys\n * @param {array} keysToTestAgainst\n * @returns {array}\n */\nconst getValidKeys = (keys, keysToTestAgainst) => {\n let validKeys = [];\n\n forEach(keys, (key) => {\n if (arrayContains(keysToTestAgainst, key)) {\n validKeys.push(key);\n }\n });\n\n return validKeys;\n};\n\n/**\n * based on the keys passed, create an object with either position\n * or size or both properties that are objects containing the respective\n * values for the associated keys\n *\n * @param {array} keys\n * @param {object} currentState\n * @param {string} positionProp\n * @param {string} sizeProp\n * @returns {object}\n */\nconst getValues = (keys, currentState, {positionProp, sizeProp}) => {\n let hasSize = false,\n hasPosition = false,\n size,\n position;\n\n if (isArray(keys)) {\n forEach(keys, (key) => {\n if (arrayContains(ALL_POSITION_KEYS, key)) {\n if (!position) {\n position = {};\n }\n\n position[key] = currentState[key];\n hasPosition = true;\n }\n\n if (arrayContains(ALL_SIZE_KEYS, key)) {\n if (!size) {\n size = {};\n }\n\n size[key] = currentState[key];\n hasSize = true;\n }\n });\n } else {\n size = {};\n position = {};\n hasSize = true;\n hasPosition = true;\n\n forEach(ALL_POSITION_KEYS, (key) => {\n position[key] = currentState[key];\n });\n\n forEach(ALL_SIZE_KEYS, (key) => {\n size[key] = currentState[key];\n });\n }\n\n let values = {};\n\n if (hasSize) {\n values[sizeProp] = size;\n }\n\n if (hasPosition) {\n values[positionProp] = position;\n }\n\n return values;\n};\n\n/**\n * iterate through keys and determine if the values have\n * changed compared to what is stored in state\n *\n * @param {array} keys\n * @param {object} values\n * @param {object} currentState\n * @returns {boolean}\n */\nconst haveValuesChanged = (keys, values, currentState) => {\n let index = -1,\n key;\n\n while (++index < keys.length) {\n key = keys[index];\n\n if (values[key] !== currentState[key]) {\n return true;\n }\n }\n\n return false;\n};\n\nexport {arrayContains};\nexport {arraySubset};\nexport {createObjectFromKeys};\nexport {forEach};\nexport {getNaturalDimensionValue};\nexport {getValidKeys};\nexport {getValues};\nexport {haveValuesChanged};\nexport {isArray};\nexport {isObject};\nexport {isString};\nexport {isUndefined};\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/utils.js\n **/","const BOUNDING_CLIENT_RECT_SIZE_KEYS = [\n 'height',\n 'width'\n];\n\nconst BOUNDING_CLIENT_RECT_POSITION_KEYS = [\n 'bottom',\n 'left',\n 'right',\n 'top'\n];\n\nconst ALL_BOUNDING_CLIENT_RECT_KEYS = [\n ...BOUNDING_CLIENT_RECT_POSITION_KEYS,\n ...BOUNDING_CLIENT_RECT_SIZE_KEYS\n];\n\nconst DOM_ELEMENT_POSITION_KEYS = [\n 'clientLeft',\n 'clientTop',\n 'offsetLeft',\n 'offsetTop',\n 'scrollLeft',\n 'scrollTop'\n];\n\nconst DOM_ELEMENT_SIZE_KEYS = [\n 'clientHeight',\n 'clientWidth',\n 'naturalHeight',\n 'naturalWidth',\n 'offsetHeight',\n 'offsetWidth',\n 'scrollHeight',\n 'scrollWidth'\n];\n\nconst ALL_DOM_ELEMENT_KEYS = [\n ...DOM_ELEMENT_POSITION_KEYS,\n ...DOM_ELEMENT_SIZE_KEYS\n];\n\nconst ALL_POSITION_KEYS = [\n ...DOM_ELEMENT_POSITION_KEYS,\n ...BOUNDING_CLIENT_RECT_POSITION_KEYS\n];\n\nconst ALL_SIZE_KEYS = [\n ...DOM_ELEMENT_SIZE_KEYS,\n ...BOUNDING_CLIENT_RECT_SIZE_KEYS\n];\n\nconst ALL_KEYS = [\n ...ALL_POSITION_KEYS,\n ...ALL_SIZE_KEYS\n];\n\nlet initialState = {},\n index = ALL_KEYS.length,\n key;\n\nwhile (index--) {\n key = ALL_KEYS[index];\n\n initialState[key] = 0;\n}\n\nexport {ALL_BOUNDING_CLIENT_RECT_KEYS};\nexport {ALL_DOM_ELEMENT_KEYS};\nexport {ALL_KEYS};\nexport {ALL_POSITION_KEYS};\nexport {ALL_SIZE_KEYS};\nexport {BOUNDING_CLIENT_RECT_POSITION_KEYS};\nexport {BOUNDING_CLIENT_RECT_SIZE_KEYS};\nexport {DOM_ELEMENT_POSITION_KEYS};\nexport {DOM_ELEMENT_SIZE_KEYS};\nexport {initialState};\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/constants.js\n **/","// external dependencies\nimport onElementResize from 'element-resize-event';\nimport React, {\n Component\n} from 'react';\nimport {\n findDOMNode\n} from 'react-dom';\n\n// utils\nimport {\n arraySubset,\n createObjectFromKeys,\n getValues,\n haveValuesChanged\n} from './utils';\n\n// constants\nimport {\n ALL_BOUNDING_CLIENT_RECT_KEYS,\n ALL_DOM_ELEMENT_KEYS,\n ALL_KEYS\n} from './constants';\n\nconst POSITION_PROP_DEFAULT = 'position';\nconst RENDER_ON_RESIZE_DEFAULT = true;\nconst SIZE_PROP_DEFAULT = 'size';\n\nlet raf;\n\n/**\n * wait to assign the raf until mount, so it has access to the\n * window object\n */\nconst setRaf = () => {\n raf = (\n window.requestAnimationFrame ||\n window.webkitRequestAnimationFrame ||\n window.mozRequestAnimationFrame ||\n function(callback) {\n window.setTimeout(callback, 1000 / 60);\n }\n );\n};\n\n/**\n * create the HOC that injects the position and size props\n * into the child (assuming they have keys that are valid\n * for one or both of those)\n *\n * @param {Component} OriginalComponent\n * @param {array} keys\n * @param {object} options={}\n * @returns {RemeasureComponent}\n */\nconst getHigherOrderComponent = (OriginalComponent, keys, options = {}) => {\n const {\n positionProp = POSITION_PROP_DEFAULT,\n renderOnResize = RENDER_ON_RESIZE_DEFAULT,\n sizeProp = SIZE_PROP_DEFAULT\n } = options;\n\n const propKeyNames = {\n positionProp,\n sizeProp\n };\n\n const boundingClientRectKeys = arraySubset(ALL_BOUNDING_CLIENT_RECT_KEYS, keys);\n const domElementKeys = arraySubset(ALL_DOM_ELEMENT_KEYS, keys);\n\n const initialState = ALL_KEYS.reduce((accumulatedInitialState, key) => {\n if (keys.includes(key)) {\n return {\n ...accumulatedInitialState,\n [key]: 0\n };\n }\n\n return accumulatedInitialState;\n }, {});\n\n if (!raf) {\n setRaf();\n }\n\n class RemeasureComponent extends Component {\n componentDidMount() {\n this.domElement = findDOMNode(this);\n\n if (renderOnResize) {\n onElementResize(this.domElement, this.setValues);\n }\n\n this.setValues();\n }\n\n componentDidUpdate() {\n this.setValues();\n }\n\n componentWillUnmount() {\n this.domElement = null;\n }\n\n state = initialState;\n\n domElement = null;\n\n /**\n * based on the current DOM element, get the values\n * and determine if the state should be updated (only\n * if things have changed)\n */\n setValues = () => {\n raf(() => {\n const domElement = this.domElement;\n const boundingClientRect = domElement.getBoundingClientRect();\n\n const values = {\n ...createObjectFromKeys(boundingClientRectKeys, boundingClientRect),\n ...createObjectFromKeys(domElementKeys, domElement)\n };\n\n if (haveValuesChanged(keys, values, this.state)) {\n this.setState(values);\n }\n });\n };\n\n render() {\n return (\n \n );\n }\n }\n\n return RemeasureComponent;\n};\n\nexport default getHigherOrderComponent;\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/getHigherOrderComponent.js\n **/","var exports = function exports(element, fn) {\n var window = this\n var document = window.document\n var isIE\n var requestFrame\n\n var attachEvent = document.attachEvent\n if (typeof navigator !== 'undefined') {\n isIE = navigator.userAgent.match(/Trident/) || navigator.userAgent.match(/Edge/)\n }\n\n requestFrame = (function () {\n var raf = window.requestAnimationFrame ||\n window.mozRequestAnimationFrame ||\n window.webkitRequestAnimationFrame ||\n function fallbackRAF(func) {\n return window.setTimeout(func, 20)\n }\n return function requestFrameFunction(func) {\n return raf(func)\n }\n })()\n\n var cancelFrame = (function () {\n var cancel = window.cancelAnimationFrame ||\n window.mozCancelAnimationFrame ||\n window.webkitCancelAnimationFrame ||\n window.clearTimeout\n return function cancelFrameFunction(id) {\n return cancel(id)\n }\n })()\n\n function resizeListener(e) {\n var win = e.target || e.srcElement\n if (win.__resizeRAF__) {\n cancelFrame(win.__resizeRAF__)\n }\n win.__resizeRAF__ = requestFrame(function () {\n var trigger = win.__resizeTrigger__\n if(trigger !== undefined) {\n trigger.__resizeListeners__.forEach(function (fn) {\n fn.call(trigger, e)\n })\n }\n })\n }\n\n function objectLoad() {\n this.contentDocument.defaultView.__resizeTrigger__ = this.__resizeElement__\n this.contentDocument.defaultView.addEventListener('resize', resizeListener)\n }\n\n if (!element.__resizeListeners__) {\n element.__resizeListeners__ = []\n if (attachEvent) {\n element.__resizeTrigger__ = element\n element.attachEvent('onresize', resizeListener)\n } else {\n if (getComputedStyle(element).position === 'static') {\n element.style.position = 'relative'\n }\n var obj = element.__resizeTrigger__ = document.createElement('object')\n obj.setAttribute('style', 'display: block; position: absolute; top: 0; left: 0; height: 100%; width: 100%; overflow: hidden; pointer-events: none; z-index: -1; opacity: 0;')\n obj.setAttribute('class', 'resize-sensor')\n obj.__resizeElement__ = element\n obj.onload = objectLoad\n obj.type = 'text/html'\n if (isIE) {\n element.appendChild(obj)\n }\n obj.data = 'about:blank'\n if (!isIE) {\n element.appendChild(obj)\n }\n }\n }\n element.__resizeListeners__.push(fn)\n}\n\nexports.unbind = function(element, fn){\n var attachEvent = document.attachEvent;\n element.__resizeListeners__.splice(element.__resizeListeners__.indexOf(fn), 1);\n if (!element.__resizeListeners__.length) {\n if (attachEvent) {\n element.detachEvent('onresize', resizeListener);\n } else {\n element.__resizeTrigger__.contentDocument.defaultView.removeEventListener('resize', resizeListener);\n element.__resizeTrigger__ = !element.removeChild(element.__resizeTrigger__);\n }\n }\n}\n\nmodule.exports = (typeof window === 'undefined') ? exports : exports.bind(window)\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/element-resize-event/index.js\n ** module id = 5\n ** module chunks = 0\n **/","module.exports = __WEBPACK_EXTERNAL_MODULE_6__;\n\n\n/*****************\n ** WEBPACK FOOTER\n ** external {\"amd\":\"react\",\"commonjs\":\"react\",\"commonjs2\":\"react\",\"root\":\"React\"}\n ** module id = 6\n ** module chunks = 0\n **/","module.exports = __WEBPACK_EXTERNAL_MODULE_7__;\n\n\n/*****************\n ** WEBPACK FOOTER\n ** external {\"amd\":\"react-dom\",\"commonjs\":\"react-dom\",\"commonjs2\":\"react-dom\",\"root\":\"ReactDOM\"}\n ** module id = 7\n ** module chunks = 0\n **/"],"sourceRoot":""}
\ No newline at end of file
+{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap 1e4158d3f18960076280","webpack:///./src/index.js","webpack:///./src/utils.js","webpack:///./src/constants.js","webpack:///./src/getHigherOrderComponent.js","webpack:///./~/element-resize-event/index.js","webpack:///external {\"amd\":\"react\",\"commonjs\":\"react\",\"commonjs2\":\"react\",\"root\":\"React\"}","webpack:///external {\"amd\":\"react-dom\",\"commonjs\":\"react-dom\",\"commonjs2\":\"react-dom\",\"root\":\"ReactDOM\"}"],"names":["measure","keys","options","position","size","positionProp","sizeProp","validKeys","OriginalComponent","NATURAL_REGEXP","toString","object","Object","prototype","call","forEach","array","fn","length","index","isArray","isObject","isString","isUndefined","arrayContains","item","indexOf","arraySubset","array1","array2","filter","includes","getNaturalDimensionValue","source","key","replace","createObjectFromKeys","shouldAlterNaturalKeys","reduce","target","getValidKeys","keysToTestAgainst","push","getValuesProperties","currentState","hasPosition","hasSize","getValues","values","haveValuesChanged","POSITION_PROP_DEFAULT","RENDER_ON_RESIZE_DEFAULT","SIZE_PROP_DEFAULT","BOUNDING_CLIENT_RECT_SIZE_KEYS","BOUNDING_CLIENT_RECT_POSITION_KEYS","ALL_BOUNDING_CLIENT_RECT_KEYS","DOM_ELEMENT_POSITION_KEYS","DOM_ELEMENT_SIZE_KEYS","ALL_DOM_ELEMENT_KEYS","ALL_POSITION_KEYS","ALL_SIZE_KEYS","ALL_KEYS","initialState","raf","setRaf","window","requestAnimationFrame","webkitRequestAnimationFrame","mozRequestAnimationFrame","callback","setTimeout","reduceStateToMatchingKeys","allKeys","desiredKeys","accumulatedInitialState","getHigherOrderComponent","renderOnResize","propKeyNames","boundingClientRectKeys","domElementKeys","RemeasureComponent","state","domElement","setValues","boundingClientRect","getBoundingClientRect","setState","props"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;ACVA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,uBAAe;AACf;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;;;;;;;;;;;;;;;;;;;mPCtCA;;;AAQA;;;AASA;;;AAhBA;;AAQA;;AASA;;;;;;AAEA;;;;;;;;AAQA,KAAMA,UAAU,SAAVA,OAAU,CAACC,IAAD,EAAOC,OAAP,EAAmB;AACjC,OAAI,qBAASD,IAAT,CAAJ,EAAoB;AAClB,SAAIE,2CAAJ;AAAA,SACIC,mCADJ;;AAGA,SAAI,qBAASF,OAAT,CAAJ,EAAuB;AAAA,mCAIjBA,OAJiB,CAEnBG,YAFmB;AAELF,eAFK;AAAA,+BAIjBD,OAJiB,CAGnBI,QAHmB;AAGTF,WAHS;AAKtB;;AAED,aAAQH,IAAR;AACE,YAAKE,QAAL;AACEF;AACA;;AAEF,YAAKG,IAAL;AACEH;AACA;;AAEF;AACEA,gBAAO,CAACA,IAAD,CAAP;AACA;AAXJ;AAaD;;AAED,OAAI,oBAAQA,IAAR,CAAJ,EAAmB;AAAA;AACjB,WAAMM,YAAY,yBAAaN,IAAb,sBAAlB;;AAEA;AAAA,YAAO,WAACO,iBAAD,EAAuB;AAC5B,kBAAO,uCAAwBA,iBAAxB,EAA2CD,SAA3C,EAAsDL,OAAtD,CAAP;AACD;AAFD;AAHiB;;AAAA;AAMlB;;AAED,OAAI,qBAASD,IAAT,CAAJ,EAAoB;AAClB,YAAO,UAACO,iBAAD,EAAuB;AAC5B,cAAO,uCAAwBA,iBAAxB,uBAAqDP,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E;AAAA;;AAAA;AAAA;AAAA,2CAqBnD;AAClB,cAAKkC,UAAL,GAAkB,2BAAY,IAAZ,CAAlB;;AAEA,aAAIN,cAAJ,EAAoB;AAClB,6CAAgB,KAAKM,UAArB,EAAiC,KAAKC,SAAtC;AACD;;AAED,cAAKA,SAAL;AACD;AA7BsE;AAAA;AAAA,4CA+BlD;AACnB,cAAKA,SAAL;AACD;AAjCsE;AAAA;AAAA,8CAmChD;AACrB,cAAKD,UAAL,GAAkB,IAAlB;AACD;;AAMD;;;;;;AA3CuE;AAAA;AAAA,gCAgE9D;AACP,gBACE,8BAAC,iBAAD,eACM,KAAKK,KADX,EAEM,sBAAUtF,IAAV,EAAgB,KAAKgF,KAArB,EAA4BJ,YAA5B,CAFN,EADF;AAMD;AAvEsE;;AAAA;AAAA;;AA0EzE,UAAOG,kBAAP;AACD,EA3ED;;mBA6EeL,uB;;;;;;;ACvJf;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA,MAAK;AACL;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;AACA,iDAAgD,oBAAoB,QAAQ,SAAS,cAAc,aAAa,kBAAkB,sBAAsB,aAAa,YAAY;AACjL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;;;;;;;AC7FA,gD;;;;;;ACAA,gD","file":"remeasure.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"react\"), require(\"react-dom\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"Remeasure\", [\"react\", \"react-dom\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"Remeasure\"] = factory(require(\"react\"), require(\"react-dom\"));\n\telse\n\t\troot[\"Remeasure\"] = factory(root[\"React\"], root[\"ReactDOM\"]);\n})(this, function(__WEBPACK_EXTERNAL_MODULE_6__, __WEBPACK_EXTERNAL_MODULE_7__) {\nreturn \n\n\n/** WEBPACK FOOTER **\n ** webpack/universalModuleDefinition\n **/"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n/** WEBPACK FOOTER **\n ** webpack/bootstrap 1e4158d3f18960076280\n **/","// utils\nimport {\n getValidKeys,\n isArray,\n isObject,\n isString\n} from './utils';\n\n// constants\nimport {\n ALL_KEYS,\n ALL_POSITION_KEYS,\n ALL_SIZE_KEYS,\n POSITION_PROP_DEFAULT,\n SIZE_PROP_DEFAULT\n} from './constants';\n\n// HOC\nimport getHigherOrderComponent from './getHigherOrderComponent';\n\n/**\n * create higher-order component that injects size and position properties\n * into OriginalComponent as an object under the prop name size and position\n *\n * @param {Component|array} keys\n * @param {object} options\n * @returns {RemeasureComponent}\n */\nconst measure = (keys, options) => {\n if (isString(keys)) {\n let position = POSITION_PROP_DEFAULT,\n size = SIZE_PROP_DEFAULT;\n\n if (isObject(options)) {\n ({\n positionProp: position = POSITION_PROP_DEFAULT,\n sizeProp: size = SIZE_PROP_DEFAULT\n } = options);\n }\n\n switch (keys) {\n case position:\n keys = ALL_POSITION_KEYS;\n break;\n\n case size:\n keys = ALL_SIZE_KEYS;\n break;\n\n default:\n keys = [keys];\n break;\n }\n }\n\n if (isArray(keys)) {\n const validKeys = getValidKeys(keys, ALL_KEYS);\n\n return (OriginalComponent) => {\n return getHigherOrderComponent(OriginalComponent, validKeys, options);\n };\n }\n\n if (isObject(keys)) {\n return (OriginalComponent) => {\n return getHigherOrderComponent(OriginalComponent, ALL_KEYS, keys);\n };\n }\n\n return getHigherOrderComponent(keys, ALL_KEYS);\n};\n\nexport default measure;\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/index.js\n **/","// constants\nimport {\n ALL_POSITION_KEYS,\n ALL_SIZE_KEYS\n} from './constants';\n\nconst NATURAL_REGEXP = /natural/;\n\n/**\n * get the toString value for the object\n *\n * @param {any} object\n * @returns {string}\n */\nconst toString = (object) => {\n return Object.prototype.toString.call(object);\n};\n\n/**\n * loop over array, executing fn\n *\n * @param {array} array\n * @param {function} fn\n */\nconst forEach = (array, fn) => {\n const length = array.length;\n\n let index = -1;\n\n while (++index < length) {\n fn(array[index], index, array);\n }\n};\n\n/**\n * determine if object is an array\n *\n * @param {any} object\n * @returns {boolean}\n */\nconst isArray = (object) => {\n return toString(object) === '[object Array]';\n};\n\n/**\n * determine if object is an object\n *\n * @param {any} object\n * @returns {boolean}\n */\nconst isObject = (object) => {\n return toString(object) === '[object Object]' && !!object;\n};\n\n/**\n * determine if object is a string\n *\n * @param {any} object\n * @returns {boolean}\n */\nconst isString = (object) => {\n return toString(object) === '[object String]';\n};\n\n/**\n * determine if object is undefined\n *\n * @param {any} object\n * @returns {boolean}\n */\nconst isUndefined = (object) => {\n return object === void 0;\n};\n\n/**\n * determine if array contains item at one of the indices\n *\n * @param {array} array\n * @param {any} item\n * @returns {boolean}\n */\nconst arrayContains = (array, item) => {\n return isArray(array) && !!~array.indexOf(item);\n};\n\n/**\n * get subset of array1 based on items existing in array2\n *\n * @param {array<*>} array1\n * @param {array<*>} array2\n * @returns {array}\n */\nconst arraySubset = (array1, array2) => {\n return array1.filter((item) => {\n return array2.includes(item);\n });\n};\n\n/**\n * For naturalHeight and naturalWidth, coalesce the values\n * with scrollHeight and scrollWIdth if the element does not\n * natively support it\n *\n * @param {HTMLElement} source\n * @param {string} key\n * @returns {number}\n */\nconst getNaturalDimensionValue = (source, key) => {\n if (isUndefined(source[key])) {\n return source[key.replace(NATURAL_REGEXP, 'scroll')];\n }\n\n return source[key];\n};\n\n/**\n * create an object based on the keys passed and their value\n * in the source object\n *\n * @param {array} keys\n * @param {function} keys.reduce\n * @param {object|ClientRect} source\n * @param {boolean} shouldAlterNaturalKeys=true\n * @returns {object}\n */\nconst createObjectFromKeys = (keys, source, shouldAlterNaturalKeys = true) => {\n return keys.reduce((target, key) => {\n return {\n ...target,\n [key]: shouldAlterNaturalKeys ? getNaturalDimensionValue(source, key) : source[key]\n };\n }, {});\n};\n\n/**\n * based on their existence in keysToTestAgainst, determine which of the keys\n * passed are considered valid\n *\n * @param {array} keys\n * @param {array} keysToTestAgainst\n * @returns {array}\n */\nconst getValidKeys = (keys, keysToTestAgainst) => {\n let validKeys = [];\n\n forEach(keys, (key) => {\n if (arrayContains(keysToTestAgainst, key)) {\n validKeys.push(key);\n }\n });\n\n return validKeys;\n};\n\n/**\n * get the position and size, and booleans to identify they're\n * intended existence in state\n *\n * @param {array} keys\n * @param {object} currentState\n * @returns {{hasPosition: boolean, hasSize: boolean, position: object, size: object}}\n */\nconst getValuesProperties = (keys, currentState) => {\n if (isArray(keys)) {\n let position = {},\n size = {},\n hasPosition = false,\n hasSize = false;\n\n forEach(keys, (key) => {\n if (arrayContains(ALL_POSITION_KEYS, key)) {\n position[key] = currentState[key];\n hasPosition = true;\n } else if (arrayContains(ALL_SIZE_KEYS, key)) {\n size[key] = currentState[key];\n hasSize = true;\n }\n });\n\n return {\n hasPosition,\n hasSize,\n position,\n size\n };\n }\n\n const position = createObjectFromKeys(ALL_POSITION_KEYS, currentState, false);\n const size = createObjectFromKeys(ALL_SIZE_KEYS, currentState, false);\n\n return {\n hasPosition: true,\n hasSize: true,\n position,\n size\n };\n};\n\n/**\n * based on the keys passed, create an object with either position\n * or size or both properties that are objects containing the respective\n * values for the associated keys\n *\n * @param {array} keys\n * @param {object} currentState\n * @param {string} positionProp\n * @param {string} sizeProp\n * @returns {object}\n */\nconst getValues = (keys, currentState, {positionProp, sizeProp}) => {\n const {\n hasSize,\n hasPosition,\n position,\n size\n } = getValuesProperties(keys, currentState);\n\n let values = {};\n\n if (hasSize) {\n values[sizeProp] = size;\n }\n\n if (hasPosition) {\n values[positionProp] = position;\n }\n\n return values;\n};\n\n/**\n * iterate through keys and determine if the values have\n * changed compared to what is stored in state\n *\n * @param {array} keys\n * @param {object} values\n * @param {object} currentState\n * @returns {boolean}\n */\nconst haveValuesChanged = (keys, values, currentState) => {\n let index = -1,\n key;\n\n while (++index < keys.length) {\n key = keys[index];\n\n if (values[key] !== currentState[key]) {\n return true;\n }\n }\n\n return false;\n};\n\nexport {arrayContains};\nexport {arraySubset};\nexport {createObjectFromKeys};\nexport {forEach};\nexport {getNaturalDimensionValue};\nexport {getValidKeys};\nexport {getValues};\nexport {haveValuesChanged};\nexport {isArray};\nexport {isObject};\nexport {isString};\nexport {isUndefined};\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/utils.js\n **/","const POSITION_PROP_DEFAULT = 'position';\nconst RENDER_ON_RESIZE_DEFAULT = true;\nconst SIZE_PROP_DEFAULT = 'size';\n\nconst BOUNDING_CLIENT_RECT_SIZE_KEYS = [\n 'height',\n 'width'\n];\n\nconst BOUNDING_CLIENT_RECT_POSITION_KEYS = [\n 'bottom',\n 'left',\n 'right',\n 'top'\n];\n\nconst ALL_BOUNDING_CLIENT_RECT_KEYS = [\n ...BOUNDING_CLIENT_RECT_POSITION_KEYS,\n ...BOUNDING_CLIENT_RECT_SIZE_KEYS\n];\n\nconst DOM_ELEMENT_POSITION_KEYS = [\n 'clientLeft',\n 'clientTop',\n 'offsetLeft',\n 'offsetTop',\n 'scrollLeft',\n 'scrollTop'\n];\n\nconst DOM_ELEMENT_SIZE_KEYS = [\n 'clientHeight',\n 'clientWidth',\n 'naturalHeight',\n 'naturalWidth',\n 'offsetHeight',\n 'offsetWidth',\n 'scrollHeight',\n 'scrollWidth'\n];\n\nconst ALL_DOM_ELEMENT_KEYS = [\n ...DOM_ELEMENT_POSITION_KEYS,\n ...DOM_ELEMENT_SIZE_KEYS\n];\n\nconst ALL_POSITION_KEYS = [\n ...DOM_ELEMENT_POSITION_KEYS,\n ...BOUNDING_CLIENT_RECT_POSITION_KEYS\n];\n\nconst ALL_SIZE_KEYS = [\n ...DOM_ELEMENT_SIZE_KEYS,\n ...BOUNDING_CLIENT_RECT_SIZE_KEYS\n];\n\nconst ALL_KEYS = [\n ...ALL_POSITION_KEYS,\n ...ALL_SIZE_KEYS\n];\n\nlet initialState = {},\n index = ALL_KEYS.length,\n key;\n\nwhile (index--) {\n key = ALL_KEYS[index];\n\n initialState[key] = 0;\n}\n\nexport {ALL_BOUNDING_CLIENT_RECT_KEYS};\nexport {ALL_DOM_ELEMENT_KEYS};\nexport {ALL_KEYS};\nexport {ALL_POSITION_KEYS};\nexport {ALL_SIZE_KEYS};\nexport {BOUNDING_CLIENT_RECT_POSITION_KEYS};\nexport {BOUNDING_CLIENT_RECT_SIZE_KEYS};\nexport {DOM_ELEMENT_POSITION_KEYS};\nexport {DOM_ELEMENT_SIZE_KEYS};\nexport {initialState};\nexport {POSITION_PROP_DEFAULT};\nexport {RENDER_ON_RESIZE_DEFAULT};\nexport {SIZE_PROP_DEFAULT};\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/constants.js\n **/","// external dependencies\nimport onElementResize from 'element-resize-event';\nimport React, {\n Component\n} from 'react';\nimport {\n findDOMNode\n} from 'react-dom';\n\n// utils\nimport {\n arraySubset,\n createObjectFromKeys,\n getValues,\n haveValuesChanged\n} from './utils';\n\n// constants\nimport {\n ALL_BOUNDING_CLIENT_RECT_KEYS,\n ALL_DOM_ELEMENT_KEYS,\n ALL_KEYS,\n POSITION_PROP_DEFAULT,\n RENDER_ON_RESIZE_DEFAULT,\n SIZE_PROP_DEFAULT\n} from './constants';\n\nlet raf;\n\n/**\n * wait to assign the raf until mount, so it has access to the\n * window object\n */\nconst setRaf = () => {\n raf = (\n window.requestAnimationFrame ||\n window.webkitRequestAnimationFrame ||\n window.mozRequestAnimationFrame ||\n function(callback) {\n window.setTimeout(callback, 1000 / 60);\n }\n );\n};\n\n/**\n * based on desiredKeys, build the initialState object\n *\n * @param {array} allKeys\n * @param {array} desiredKeys\n * @returns {array}\n */\nconst reduceStateToMatchingKeys = (allKeys, desiredKeys) => {\n return allKeys.reduce((accumulatedInitialState, key) => {\n if (desiredKeys.includes(key)) {\n return {\n ...accumulatedInitialState,\n [key]: 0\n };\n }\n\n return accumulatedInitialState;\n }, {});\n};\n\n/**\n * create the HOC that injects the position and size props\n * into the child (assuming they have keys that are valid\n * for one or both of those)\n *\n * @param {Component} OriginalComponent\n * @param {array} keys\n * @param {object} options={}\n * @returns {RemeasureComponent}\n */\nconst getHigherOrderComponent = (OriginalComponent, keys, options = {}) => {\n const {\n positionProp = POSITION_PROP_DEFAULT,\n renderOnResize = RENDER_ON_RESIZE_DEFAULT,\n sizeProp = SIZE_PROP_DEFAULT\n } = options;\n\n const propKeyNames = {\n positionProp,\n sizeProp\n };\n\n const boundingClientRectKeys = arraySubset(ALL_BOUNDING_CLIENT_RECT_KEYS, keys);\n const domElementKeys = arraySubset(ALL_DOM_ELEMENT_KEYS, keys);\n const initialState = reduceStateToMatchingKeys(ALL_KEYS, keys);\n\n if (!raf) {\n setRaf();\n }\n\n class RemeasureComponent extends Component {\n componentDidMount() {\n this.domElement = findDOMNode(this);\n\n if (renderOnResize) {\n onElementResize(this.domElement, this.setValues);\n }\n\n this.setValues();\n }\n\n componentDidUpdate() {\n this.setValues();\n }\n\n componentWillUnmount() {\n this.domElement = null;\n }\n\n state = initialState;\n\n domElement = null;\n\n /**\n * based on the current DOM element, get the values\n * and determine if the state should be updated (only\n * if things have changed)\n */\n setValues = () => {\n raf(() => {\n const domElement = this.domElement;\n const boundingClientRect = domElement.getBoundingClientRect();\n\n const values = {\n ...createObjectFromKeys(boundingClientRectKeys, boundingClientRect),\n ...createObjectFromKeys(domElementKeys, domElement)\n };\n\n if (haveValuesChanged(keys, values, this.state)) {\n this.setState(values);\n }\n });\n };\n\n render() {\n return (\n \n );\n }\n }\n\n return RemeasureComponent;\n};\n\nexport default getHigherOrderComponent;\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/getHigherOrderComponent.js\n **/","var exports = function exports(element, fn) {\n var window = this\n var document = window.document\n var isIE\n var requestFrame\n\n var attachEvent = document.attachEvent\n if (typeof navigator !== 'undefined') {\n isIE = navigator.userAgent.match(/Trident/) || navigator.userAgent.match(/Edge/)\n }\n\n requestFrame = (function () {\n var raf = window.requestAnimationFrame ||\n window.mozRequestAnimationFrame ||\n window.webkitRequestAnimationFrame ||\n function fallbackRAF(func) {\n return window.setTimeout(func, 20)\n }\n return function requestFrameFunction(func) {\n return raf(func)\n }\n })()\n\n var cancelFrame = (function () {\n var cancel = window.cancelAnimationFrame ||\n window.mozCancelAnimationFrame ||\n window.webkitCancelAnimationFrame ||\n window.clearTimeout\n return function cancelFrameFunction(id) {\n return cancel(id)\n }\n })()\n\n function resizeListener(e) {\n var win = e.target || e.srcElement\n if (win.__resizeRAF__) {\n cancelFrame(win.__resizeRAF__)\n }\n win.__resizeRAF__ = requestFrame(function () {\n var trigger = win.__resizeTrigger__\n if(trigger !== undefined) {\n trigger.__resizeListeners__.forEach(function (fn) {\n fn.call(trigger, e)\n })\n }\n })\n }\n\n function objectLoad() {\n this.contentDocument.defaultView.__resizeTrigger__ = this.__resizeElement__\n this.contentDocument.defaultView.addEventListener('resize', resizeListener)\n }\n\n if (!element.__resizeListeners__) {\n element.__resizeListeners__ = []\n if (attachEvent) {\n element.__resizeTrigger__ = element\n element.attachEvent('onresize', resizeListener)\n } else {\n if (getComputedStyle(element).position === 'static') {\n element.style.position = 'relative'\n }\n var obj = element.__resizeTrigger__ = document.createElement('object')\n obj.setAttribute('style', 'display: block; position: absolute; top: 0; left: 0; height: 100%; width: 100%; overflow: hidden; pointer-events: none; z-index: -1; opacity: 0;')\n obj.setAttribute('class', 'resize-sensor')\n obj.__resizeElement__ = element\n obj.onload = objectLoad\n obj.type = 'text/html'\n if (isIE) {\n element.appendChild(obj)\n }\n obj.data = 'about:blank'\n if (!isIE) {\n element.appendChild(obj)\n }\n }\n }\n element.__resizeListeners__.push(fn)\n}\n\nexports.unbind = function(element, fn){\n var attachEvent = document.attachEvent;\n element.__resizeListeners__.splice(element.__resizeListeners__.indexOf(fn), 1);\n if (!element.__resizeListeners__.length) {\n if (attachEvent) {\n element.detachEvent('onresize', resizeListener);\n } else {\n element.__resizeTrigger__.contentDocument.defaultView.removeEventListener('resize', resizeListener);\n element.__resizeTrigger__ = !element.removeChild(element.__resizeTrigger__);\n }\n }\n}\n\nmodule.exports = (typeof window === 'undefined') ? exports : exports.bind(window)\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/element-resize-event/index.js\n ** module id = 5\n ** module chunks = 0\n **/","module.exports = __WEBPACK_EXTERNAL_MODULE_6__;\n\n\n/*****************\n ** WEBPACK FOOTER\n ** external {\"amd\":\"react\",\"commonjs\":\"react\",\"commonjs2\":\"react\",\"root\":\"React\"}\n ** module id = 6\n ** module chunks = 0\n **/","module.exports = __WEBPACK_EXTERNAL_MODULE_7__;\n\n\n/*****************\n ** WEBPACK FOOTER\n ** external {\"amd\":\"react-dom\",\"commonjs\":\"react-dom\",\"commonjs2\":\"react-dom\",\"root\":\"ReactDOM\"}\n ** module id = 7\n ** module chunks = 0\n **/"],"sourceRoot":""}
\ No newline at end of file
diff --git a/dist/remeasure.min.js b/dist/remeasure.min.js
index 6ed4ac3..acfc368 100644
--- a/dist/remeasure.min.js
+++ b/dist/remeasure.min.js
@@ -1 +1 @@
-!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("react-dom")):"function"==typeof define&&define.amd?define("Remeasure",["react","react-dom"],t):"object"==typeof exports?exports.Remeasure=t(require("react"),require("react-dom")):e.Remeasure=t(e.React,e.ReactDOM)}(this,function(e,t){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";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},o=n(2),a=n(3),u=n(4),s=r(u),c="position",f="size",l=function(e,t){if((0,o.isString)(e)){var n=c,r=f;if((0,o.isObject)(t)){var u=t.positionProp;n=void 0===u?c:u;var l=t.sizeProp;r=void 0===l?f:l}switch(e){case n:e=a.ALL_POSITION_KEYS;break;case r:e=a.ALL_SIZE_KEYS;break;default:e=[e]}}if((0,o.isArray)(e)){var _=function(){var n=(0,o.getValidKeys)(e,a.ALL_KEYS);return{v:function(e){return(0,s.default)(e,n,t)}}}();if("object"===("undefined"==typeof _?"undefined":i(_)))return _.v}return(0,o.isObject)(e)?function(t){return(0,s.default)(t,a.ALL_KEYS,e)}:(0,s.default)(e,a.ALL_KEYS)};t.default=l,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isUndefined=t.isString=t.isObject=t.isArray=t.haveValuesChanged=t.getValues=t.getValidKeys=t.getNaturalDimensionValue=t.forEach=t.createObjectFromKeys=t.arraySubset=t.arrayContains=void 0;var r=n(3),i=/natural/,o=function(e){return Object.prototype.toString.call(e)},a=function(e,t){for(var n=e.length,r=-1;++r {
);
};
+/**
+ * based on desiredKeys, build the initialState object
+ *
+ * @param {array} allKeys
+ * @param {array} desiredKeys
+ * @returns {array}
+ */
+const reduceStateToMatchingKeys = (allKeys, desiredKeys) => {
+ return allKeys.reduce((accumulatedInitialState, key) => {
+ if (desiredKeys.includes(key)) {
+ return {
+ ...accumulatedInitialState,
+ [key]: 0
+ };
+ }
+
+ return accumulatedInitialState;
+ }, {});
+};
+
/**
* create the HOC that injects the position and size props
* into the child (assuming they have keys that are valid
@@ -67,17 +86,7 @@ const getHigherOrderComponent = (OriginalComponent, keys, options = {}) => {
const boundingClientRectKeys = arraySubset(ALL_BOUNDING_CLIENT_RECT_KEYS, keys);
const domElementKeys = arraySubset(ALL_DOM_ELEMENT_KEYS, keys);
-
- const initialState = ALL_KEYS.reduce((accumulatedInitialState, key) => {
- if (keys.includes(key)) {
- return {
- ...accumulatedInitialState,
- [key]: 0
- };
- }
-
- return accumulatedInitialState;
- }, {});
+ const initialState = reduceStateToMatchingKeys(ALL_KEYS, keys);
if (!raf) {
setRaf();
diff --git a/src/index.js b/src/index.js
index cbc9f3e..33a45d9 100644
--- a/src/index.js
+++ b/src/index.js
@@ -10,15 +10,14 @@ import {
import {
ALL_KEYS,
ALL_POSITION_KEYS,
- ALL_SIZE_KEYS
+ ALL_SIZE_KEYS,
+ POSITION_PROP_DEFAULT,
+ SIZE_PROP_DEFAULT
} from './constants';
// HOC
import getHigherOrderComponent from './getHigherOrderComponent';
-const POSITION_PROP_DEFAULT = 'position';
-const SIZE_PROP_DEFAULT = 'size';
-
/**
* create higher-order component that injects size and position properties
* into OriginalComponent as an object under the prop name size and position
diff --git a/src/utils.js b/src/utils.js
index baa092c..b2fdadd 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -118,17 +118,18 @@ const getNaturalDimensionValue = (source, key) => {
* in the source object
*
* @param {array} keys
+ * @param {function} keys.reduce
* @param {object|ClientRect} source
+ * @param {boolean} shouldAlterNaturalKeys=true
* @returns {object}
*/
-const createObjectFromKeys = (keys, source) => {
- let target = {};
-
- forEach(keys, (key) => {
- target[key] = NATURAL_REGEXP.test(key) ? getNaturalDimensionValue(source, key) : source[key];
- });
-
- return target;
+const createObjectFromKeys = (keys, source, shouldAlterNaturalKeys = true) => {
+ return keys.reduce((target, key) => {
+ return {
+ ...target,
+ [key]: shouldAlterNaturalKeys ? getNaturalDimensionValue(source, key) : source[key]
+ };
+ }, {});
};
/**
@@ -152,57 +153,68 @@ const getValidKeys = (keys, keysToTestAgainst) => {
};
/**
- * based on the keys passed, create an object with either position
- * or size or both properties that are objects containing the respective
- * values for the associated keys
+ * get the position and size, and booleans to identify they're
+ * intended existence in state
*
* @param {array} keys
* @param {object} currentState
- * @param {string} positionProp
- * @param {string} sizeProp
- * @returns {object}
+ * @returns {{hasPosition: boolean, hasSize: boolean, position: object, size: object}}
*/
-const getValues = (keys, currentState, {positionProp, sizeProp}) => {
- let hasSize = false,
- hasPosition = false,
- size,
- position;
-
+const getValuesProperties = (keys, currentState) => {
if (isArray(keys)) {
+ let position = {},
+ size = {},
+ hasPosition = false,
+ hasSize = false;
+
forEach(keys, (key) => {
if (arrayContains(ALL_POSITION_KEYS, key)) {
- if (!position) {
- position = {};
- }
-
position[key] = currentState[key];
hasPosition = true;
- }
-
- if (arrayContains(ALL_SIZE_KEYS, key)) {
- if (!size) {
- size = {};
- }
-
+ } else if (arrayContains(ALL_SIZE_KEYS, key)) {
size[key] = currentState[key];
hasSize = true;
}
});
- } else {
- size = {};
- position = {};
- hasSize = true;
- hasPosition = true;
-
- forEach(ALL_POSITION_KEYS, (key) => {
- position[key] = currentState[key];
- });
- forEach(ALL_SIZE_KEYS, (key) => {
- size[key] = currentState[key];
- });
+ return {
+ hasPosition,
+ hasSize,
+ position,
+ size
+ };
}
+ const position = createObjectFromKeys(ALL_POSITION_KEYS, currentState, false);
+ const size = createObjectFromKeys(ALL_SIZE_KEYS, currentState, false);
+
+ return {
+ hasPosition: true,
+ hasSize: true,
+ position,
+ size
+ };
+};
+
+/**
+ * based on the keys passed, create an object with either position
+ * or size or both properties that are objects containing the respective
+ * values for the associated keys
+ *
+ * @param {array} keys
+ * @param {object} currentState
+ * @param {string} positionProp
+ * @param {string} sizeProp
+ * @returns {object}
+ */
+const getValues = (keys, currentState, {positionProp, sizeProp}) => {
+ const {
+ hasPosition,
+ hasSize,
+ position,
+ size
+ } = getValuesProperties(keys, currentState);
+
let values = {};
if (hasSize) {
diff --git a/webpack.config.dev.js b/webpack.config.dev.js
index 943187b..25205c0 100644
--- a/webpack.config.dev.js
+++ b/webpack.config.dev.js
@@ -24,7 +24,7 @@ module.exports = {
}
},
- devtool: '#source-map',
+ devtool: '#cheap-module-eval-source-map',
entry: [
path.resolve (__dirname, 'DEV_ONLY', 'App.js')