size-sensor
Advanced tools
Comparing version 0.2.5 to 0.2.6
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.sizeSensor={})}(this,function(e){"use strict";var t=1,n=function(e){var t=void 0,n=[],i=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:60,n=null;return function(){for(var i=this,o=arguments.length,r=Array(o),u=0;u<o;u++)r[u]=arguments[u];clearTimeout(n),n=setTimeout(function(){e.apply(i,r)},t)}}(function(){n.forEach(function(t){t(e)})}),o=function(){t&&t.parentNode&&(t.contentDocument&&t.contentDocument.defaultView.removeEventListener("resize",i),t.parentNode.removeChild(t),t=void 0,n=[])};return{element:e,bind:function(o){t||(t=function(){"static"===getComputedStyle(e).position&&(e.style.position="relative");var t=document.createElement("object");return t.onload=function(){t.contentDocument.defaultView.addEventListener("resize",i),i()},t.setAttribute("style","display:block;position:absolute;top:0;left:0;height:100%;width:100%;overflow:hidden;pointer-events:none;z-index:-1;opacity:0"),t.setAttribute("class","size-sensor-object"),t.setAttribute("tabindex","-1"),t.type="text/html",e.appendChild(t),t.data="about:blank",t}()),-1===n.indexOf(o)&&n.push(o)},destroy:o,unbind:function(e){var i=n.indexOf(e);-1!==i&&n.splice(i,1),0===n.length&&t&&o()}}},i={},o=function(e){var o=e.getAttribute("size-sensor-id");if(o&&i[o])return i[o];var r=""+t++;e.setAttribute("size-sensor-id",r);var u=n(e);return i[r]=u,u};e.bind=function(e,t){var n=o(e);return n.bind(t),function(){n.unbind(t)}},e.clear=function(e){!function(e){var t=e.element.getAttribute("size-sensor-id");e.element.removeAttribute("size-sensor-id"),e.destroy(),t&&i[t]&&delete i[t]}(o(e))},e.ver="0.2.4",Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).sizeSensor={})}(this,function(e){"use strict";function u(o){var r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:60,u=null;return function(){for(var e=this,t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];clearTimeout(u),u=setTimeout(function(){o.apply(e,n)},r)}}function i(e){var t=e.getAttribute(r);if(t&&d[t])return d[t];var n="".concat(o++);e.setAttribute(r,n);var i=c(e);return d[n]=i}var o=1,r="size-sensor-id",c="undefined"!=typeof ResizeObserver?function(t){function n(){i.disconnect(),o=[],i=void 0}var i=void 0,o=[],r=u(function(){o.forEach(function(e){e(t)})});return{element:t,bind:function(e){i=i||function(){var e=new ResizeObserver(r);return e.observe(t),r(),e}(),-1===o.indexOf(e)&&o.push(e)},destroy:n,unbind:function(e){var t=o.indexOf(e);-1!==t&&o.splice(t,1),0===o.length&&i&&n()}}}:function(t){function n(){i&&i.parentNode&&(i.contentDocument&&i.contentDocument.defaultView.removeEventListener("resize",r),i.parentNode.removeChild(i),i=void 0,o=[])}var i=void 0,o=[],r=u(function(){o.forEach(function(e){e(t)})});return{element:t,bind:function(e){i=i||function(){"static"===getComputedStyle(t).position&&(t.style.position="relative");var e=document.createElement("object");return e.onload=function(){e.contentDocument.defaultView.addEventListener("resize",r),r()},e.setAttribute("style","display:block;position:absolute;top:0;left:0;height:100%;width:auto;overflow:hidden;pointer-events:none;z-index:-1;opacity:0"),e.setAttribute("class","size-sensor-object"),e.setAttribute("tabindex","-1"),e.type="text/html",t.appendChild(e),e.data="about:blank",e}(),-1===o.indexOf(e)&&o.push(e)},destroy:n,unbind:function(e){var t=o.indexOf(e);-1!==t&&o.splice(t,1),0===o.length&&i&&n()}}},d={};e.bind=function(e,t){var n=i(e);return n.bind(t),function(){n.unbind(t)}},e.clear=function(e){!function(e){var t=e.element.getAttribute(r);e.element.removeAttribute(r),e.destroy(),t&&d[t]&&delete d[t]}(i(e))},e.ver="0.2.7",Object.defineProperty(e,"__esModule",{value:!0})}); |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,2 +6,4 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.SensorTabIndex = exports.SensorClassName = exports.SensorStyle = exports.SizeSensorId = void 0; | ||
/** | ||
@@ -11,9 +13,9 @@ * Created by hustcc on 18/6/9. | ||
*/ | ||
var SizeSensorId = exports.SizeSensorId = 'size-sensor-id'; | ||
var SensorStyle = exports.SensorStyle = 'display:block;position:absolute;top:0;left:0;height:100%;width:100%;overflow:hidden;pointer-events:none;z-index:-1;opacity:0'; | ||
var SensorClassName = exports.SensorClassName = 'size-sensor-object'; | ||
var SensorTabIndex = exports.SensorTabIndex = '-1'; | ||
var SizeSensorId = 'size-sensor-id'; | ||
exports.SizeSensorId = SizeSensorId; | ||
var SensorStyle = 'display:block;position:absolute;top:0;left:0;height:100%;width:auto;overflow:hidden;pointer-events:none;z-index:-1;opacity:0'; | ||
exports.SensorStyle = SensorStyle; | ||
var SensorClassName = 'size-sensor-object'; | ||
exports.SensorClassName = SensorClassName; | ||
var SensorTabIndex = '-1'; | ||
exports.SensorTabIndex = SensorTabIndex; |
@@ -6,2 +6,3 @@ "use strict"; | ||
}); | ||
exports["default"] = void 0; | ||
@@ -12,12 +13,9 @@ /** | ||
*/ | ||
exports.default = function (fn) { | ||
var _default = function _default(fn) { | ||
var delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 60; | ||
var timer = null; | ||
return function () { | ||
var _this = this; | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
@@ -27,3 +25,2 @@ } | ||
clearTimeout(timer); | ||
timer = setTimeout(function () { | ||
@@ -35,2 +32,2 @@ fn.apply(_this, args); | ||
module.exports = exports["default"]; | ||
exports["default"] = _default; |
@@ -6,2 +6,4 @@ "use strict"; | ||
}); | ||
exports["default"] = void 0; | ||
/** | ||
@@ -11,9 +13,12 @@ * Created by hustcc on 18/6/9. | ||
*/ | ||
var id = 1; | ||
/** | ||
* generate unique id in application | ||
* @return {string} | ||
*/ | ||
exports.default = function () { | ||
return "" + id++; | ||
var _default = function _default() { | ||
return "".concat(id++); | ||
}; | ||
module.exports = exports["default"]; | ||
exports["default"] = _default; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,18 +6,21 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.ver = exports.clear = exports.bind = undefined; | ||
exports.ver = exports.clear = exports.bind = void 0; | ||
var _sensorPool = require('./sensorPool'); | ||
var _sensorPool = require("./sensorPool"); | ||
/** | ||
* 对外暴露的 bind 方法 | ||
* Created by hustcc on 18/6/9.[高考时间] | ||
* Contract: i@hust.cc | ||
*/ | ||
/** | ||
* bind an element with resize callback function | ||
* @param {*} element | ||
* @param {*} cb | ||
*/ | ||
var bind = exports.bind = function bind(element, cb) { | ||
var sensor = (0, _sensorPool.getSensor)(element); | ||
var bind = function bind(element, cb) { | ||
var sensor = (0, _sensorPool.getSensor)(element); // listen with callback | ||
// 绑定新的方法 | ||
sensor.bind(cb); | ||
sensor.bind(cb); // return unbind function | ||
// 返回 unbind 方法 | ||
return function () { | ||
@@ -27,18 +30,17 @@ sensor.unbind(cb); | ||
}; | ||
/** | ||
* 清空一个 element 中的所有监听 | ||
* clear all the listener and sensor of an element | ||
* @param element | ||
*/ | ||
/** | ||
* Created by hustcc on 18/6/9.[高考时间] | ||
* Contract: i@hust.cc | ||
*/ | ||
var clear = exports.clear = function clear(element) { | ||
exports.bind = bind; | ||
var clear = function clear(element) { | ||
var sensor = (0, _sensorPool.getSensor)(element); | ||
(0, _sensorPool.removeSensor)(sensor); | ||
}; | ||
var ver = exports.ver = '0.2.4'; | ||
exports.clear = clear; | ||
var ver = "0.2.7"; | ||
exports.ver = ver; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,49 +6,43 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.removeSensor = exports.getSensor = undefined; | ||
exports.removeSensor = exports.getSensor = void 0; | ||
var _id = require('./id'); | ||
var _id = _interopRequireDefault(require("./id")); | ||
var _id2 = _interopRequireDefault(_id); | ||
var _sensors = require("./sensors"); | ||
var _sensors = require('./sensors'); | ||
var _constant = require("./constant"); | ||
var _constant = require('./constant'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
/** | ||
* Created by hustcc on 18/6/9. | ||
* Contract: i@hust.cc | ||
*/ | ||
/** | ||
* all the sensor objects. | ||
* 传感器池子 | ||
* sensor pool | ||
*/ | ||
var Sensors = {}; | ||
/** | ||
* 获取 sensor | ||
* get one sensor | ||
* @param element | ||
* @returns {*} | ||
*/ | ||
/** | ||
* Created by hustcc on 18/6/9. | ||
* Contract: i@hust.cc | ||
*/ | ||
var getSensor = exports.getSensor = function getSensor(element) { | ||
var sensorId = element.getAttribute(_constant.SizeSensorId); | ||
var getSensor = function getSensor(element) { | ||
var sensorId = element.getAttribute(_constant.SizeSensorId); // 1. if the sensor exists, then use it | ||
// 1. 已经存在,则直接取这个 sensor | ||
if (sensorId && Sensors[sensorId]) { | ||
return Sensors[sensorId]; | ||
} | ||
} // 2. not exist, then create one | ||
// 2. 不存在则创建 | ||
var newId = (0, _id2.default)(); | ||
var newId = (0, _id["default"])(); | ||
element.setAttribute(_constant.SizeSensorId, newId); | ||
var sensor = (0, _sensors.createSensor)(element); // add sensor into pool | ||
var sensor = (0, _sensors.createSensor)(element); | ||
// 添加到池子中 | ||
Sensors[newId] = sensor; | ||
return sensor; | ||
}; | ||
/** | ||
@@ -58,14 +52,18 @@ * 移除 sensor | ||
*/ | ||
var removeSensor = exports.removeSensor = function removeSensor(sensor) { | ||
var sensorId = sensor.element.getAttribute(_constant.SizeSensorId); | ||
// 移除 attribute | ||
sensor.element.removeAttribute(_constant.SizeSensorId); | ||
// 移除 sensor 对应的 事件 和 dom 结构 | ||
sensor.destroy(); | ||
// 存在则从 pool 中移除 | ||
exports.getSensor = getSensor; | ||
var removeSensor = function removeSensor(sensor) { | ||
var sensorId = sensor.element.getAttribute(_constant.SizeSensorId); // remove attribute | ||
sensor.element.removeAttribute(_constant.SizeSensorId); // remove event, dom of the sensor used | ||
sensor.destroy(); // exist, then remove from pool | ||
if (sensorId && Sensors[sensorId]) { | ||
delete Sensors[sensorId]; | ||
} | ||
}; | ||
}; | ||
exports.removeSensor = removeSensor; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,20 +6,18 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.createSensor = undefined; | ||
exports.createSensor = void 0; | ||
var _object = require('./object'); | ||
var _object = require("./object"); | ||
// import { createSensor as createResizeObserverSensor } from './resizeObserver'; | ||
var _resizeObserver = require("./resizeObserver"); | ||
/** | ||
* 传感器使用策略 | ||
* Created by hustcc on 18/7/5. | ||
* Contract: i@hust.cc | ||
*/ | ||
var createSensorFunc = function createSensorFunc() { | ||
return _object.createSensor; | ||
// 部分浏览器 ResizeObserver 出现 crash | ||
// return typeof ResizeObserver !== 'undefined' ? createResizeObserverSensor : createObjectSensor; | ||
}; /** | ||
* Created by hustcc on 18/7/5. | ||
* Contract: i@hust.cc | ||
*/ | ||
var createSensor = exports.createSensor = createSensorFunc(); | ||
/** | ||
* sensor strategies | ||
*/ | ||
// export const createSensor = createObjectSensor; | ||
var createSensor = typeof ResizeObserver !== 'undefined' ? _resizeObserver.createSensor : _object.createSensor; | ||
exports.createSensor = createSensor; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,12 +6,10 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.createSensor = undefined; | ||
exports.createSensor = void 0; | ||
var _debounce = require('../debounce'); | ||
var _debounce = _interopRequireDefault(require("../debounce")); | ||
var _debounce2 = _interopRequireDefault(_debounce); | ||
var _constant = require("../constant"); | ||
var _constant = require('../constant'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
/** | ||
@@ -21,15 +19,13 @@ * Created by hustcc on 18/6/9. | ||
*/ | ||
var createSensor = function createSensor(element) { | ||
var sensor = undefined; // callback | ||
var createSensor = exports.createSensor = function createSensor(element) { | ||
// 感应器 | ||
var sensor = undefined; | ||
// callback | ||
var listeners = []; | ||
/** | ||
* 创建 sensor 的 object DOM | ||
* create object DOM of sensor | ||
* @returns {HTMLObjectElement} | ||
*/ | ||
var newSensor = function newSensor() { | ||
// 调整样式 | ||
// adjust style | ||
if (getComputedStyle(element).position === 'static') { | ||
@@ -40,24 +36,26 @@ element.style.position = 'relative'; | ||
var obj = document.createElement('object'); | ||
obj.onload = function () { | ||
obj.contentDocument.defaultView.addEventListener('resize', resizeListener); | ||
// 直接触发一次 resize | ||
obj.contentDocument.defaultView.addEventListener('resize', resizeListener); // 直接触发一次 resize | ||
resizeListener(); | ||
}; | ||
obj.setAttribute('style', _constant.SensorStyle); | ||
obj.setAttribute('class', _constant.SensorClassName); | ||
obj.setAttribute('tabindex', _constant.SensorTabIndex); | ||
obj.type = 'text/html'; | ||
obj.type = 'text/html'; // append into dom | ||
// 添加到 dom 结构中 | ||
element.appendChild(obj); | ||
// 对于 ie 需要滞后,否则白屏,所以放到后面 | ||
element.appendChild(obj); // for ie, should set data attribute delay, or will be white screen | ||
obj.data = 'about:blank'; | ||
return obj; | ||
}; | ||
/** | ||
* 统一触发 listeners | ||
* trigger listeners | ||
*/ | ||
var resizeListener = (0, _debounce2.default)(function () { | ||
// 依次触发执行 | ||
var resizeListener = (0, _debounce["default"])(function () { | ||
// trigger all listener | ||
listeners.forEach(function (listener) { | ||
@@ -67,9 +65,9 @@ listener(element); | ||
}); | ||
/** | ||
* 监听某一个 callback | ||
* listen with one callback function | ||
* @param cb | ||
*/ | ||
var bind = function bind(cb) { | ||
// 如果不存在 sensor,则创建一个 object | ||
// if not exist sensor, then create one | ||
if (!sensor) { | ||
@@ -83,15 +81,17 @@ sensor = newSensor(); | ||
}; | ||
/** | ||
* 完全 destroy | ||
* destroy all | ||
*/ | ||
var destroy = function destroy() { | ||
if (sensor && sensor.parentNode) { | ||
if (sensor.contentDocument) { | ||
// 移除事件 | ||
// remote event | ||
sensor.contentDocument.defaultView.removeEventListener('resize', resizeListener); | ||
} | ||
// 移除 dom | ||
sensor.parentNode.removeChild(sensor); | ||
// 初始化 | ||
} // remove dom | ||
sensor.parentNode.removeChild(sensor); // initial variable | ||
sensor = undefined; | ||
@@ -101,15 +101,17 @@ listeners = []; | ||
}; | ||
/** | ||
* 取消绑定 | ||
* cancel listener bind | ||
* @param cb | ||
*/ | ||
var unbind = function unbind(cb) { | ||
var idx = listeners.indexOf(cb); | ||
if (idx !== -1) { | ||
listeners.splice(idx, 1); | ||
} | ||
} // no listener, and sensor is exist | ||
// then destroy the sensor | ||
// 不存在 listener,并且存在 sensor object | ||
// 则移除 object | ||
if (listeners.length === 0 && sensor) { | ||
@@ -126,2 +128,4 @@ destroy(); | ||
}; | ||
}; | ||
}; | ||
exports.createSensor = createSensor; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,21 +6,22 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.createSensor = undefined; | ||
exports.createSensor = void 0; | ||
var _debounce = require('../debounce'); | ||
var _debounce = _interopRequireDefault(require("../debounce")); | ||
var _debounce2 = _interopRequireDefault(_debounce); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
/** | ||
* Created by hustcc on 18/7/5. | ||
* Contract: i@hust.cc | ||
*/ | ||
var createSensor = function createSensor(element) { | ||
var sensor = undefined; // callback | ||
var createSensor = exports.createSensor = function createSensor(element) { | ||
// 感应器 | ||
var sensor = undefined; | ||
// callback | ||
var listeners = []; | ||
/** | ||
* 统一触发 listeners | ||
* trigger listeners | ||
*/ | ||
var resizeListener = (0, _debounce2.default)(function () { | ||
// 依次触发执行 | ||
var resizeListener = (0, _debounce["default"])(function () { | ||
// trigger all | ||
listeners.forEach(function (listener) { | ||
@@ -30,21 +31,21 @@ listener(element); | ||
}); | ||
/** | ||
* 创建 sensor 的 object DOM | ||
* @returns {HTMLObjectElement} | ||
* create ResizeObserver sensor | ||
* @returns | ||
*/ | ||
var newSensor = function newSensor() { | ||
var sensor = new ResizeObserver(resizeListener); | ||
// 监听 element | ||
sensor.observe(element); | ||
var s = new ResizeObserver(resizeListener); // listen element | ||
// 直接触发一次 | ||
s.observe(element); // trigger once | ||
resizeListener(); | ||
return sensor; | ||
return s; | ||
}; | ||
/** | ||
* 监听某一个 callback | ||
* listen with callback | ||
* @param cb | ||
*/ | ||
var bind = function bind(cb) { | ||
@@ -59,25 +60,27 @@ if (!sensor) { | ||
}; | ||
/** | ||
* 完全 destroy | ||
* destroy | ||
*/ | ||
var destroy = function destroy() { | ||
sensor.disconnect(); | ||
listeners = []; | ||
sensor = undefined; | ||
}; | ||
/** | ||
* 取消绑定 | ||
* cancel bind | ||
* @param cb | ||
*/ | ||
var unbind = function unbind(cb) { | ||
var idx = listeners.indexOf(cb); | ||
if (idx !== -1) { | ||
listeners.splice(idx, 1); | ||
} | ||
} // no listener, and sensor is exist | ||
// then destroy the sensor | ||
// 不存在 listener,并且存在 sensor object | ||
// 则移除 object | ||
if (listeners.length === 0 && sensor) { | ||
@@ -94,5 +97,4 @@ destroy(); | ||
}; | ||
}; /** | ||
* Created by hustcc on 18/7/5. | ||
* Contract: i@hust.cc | ||
*/ | ||
}; | ||
exports.createSensor = createSensor; |
@@ -6,2 +6,4 @@ "use strict"; | ||
}); | ||
exports.isIE = void 0; | ||
/** | ||
@@ -13,7 +15,9 @@ * Created by hustcc on 18/6/22. | ||
/** | ||
* 是否是 ie,对于 ie 这种东西需要有额外处理! | ||
* whether is ie, should do something special for ie | ||
* @returns {RegExpMatchArray | null} | ||
*/ | ||
var isIE = exports.isIE = function isIE() { | ||
var isIE = function isIE() { | ||
return navigator.userAgent.match(/Trident/) || navigator.userAgent.match(/Edge/); | ||
}; | ||
}; | ||
exports.isIE = isIE; |
{ | ||
"name": "size-sensor", | ||
"version": "0.2.5", | ||
"version": "0.2.6", | ||
"description": "DOM element size sensor which will callback when size changed.", | ||
@@ -8,3 +8,4 @@ "main": "lib/index.js", | ||
"scripts": { | ||
"coveralls": "cat ./coverage/lcov.info | coveralls", | ||
"debug": "cross-env NODE_ENV=babel cross-env DEBUG_MODE=1 jest", | ||
"test": "cross-env NODE_ENV=babel jest", | ||
"build:umd": "rimraf ./dist && cross-env NODE_ENV=rollup rollup -c", | ||
@@ -32,14 +33,28 @@ "build:lib": "rimraf ./lib && cross-env NODE_ENV=babel babel src -d lib", | ||
"devDependencies": { | ||
"babel-cli": "^6.26.0", | ||
"babel-plugin-add-module-exports": "^0.2.1", | ||
"@babel/cli": "^7.6.0", | ||
"@babel/core": "^7.6.0", | ||
"@babel/preset-env": "^7.6.0", | ||
"babel-jest": "^24.9.0", | ||
"babel-plugin-version": "^0.2.1", | ||
"babel-preset-env": "^1.6.1", | ||
"cross-env": "^5.1.3", | ||
"jest": "^24.9.0", | ||
"jest-electron": "^0.1.6", | ||
"rimraf": "^2.6.2", | ||
"rollup": "^0.58.1", | ||
"rollup-plugin-babel": "^3.0.4", | ||
"rollup-plugin-node-resolve": "^3.3.0", | ||
"rollup-plugin-uglify": "^3.0.0", | ||
"rollup": "^1.21.4", | ||
"rollup-plugin-babel": "^4.3.3", | ||
"rollup-plugin-node-resolve": "^5.2.0", | ||
"rollup-plugin-uglify": "^6.0.3", | ||
"size-limit": "^0.18.2" | ||
}, | ||
"jest": { | ||
"runner": "jest-electron/runner", | ||
"testEnvironment": "jest-electron/environment", | ||
"collectCoverage": true, | ||
"collectCoverageFrom": [ | ||
"src/**/*.{js,jsx}", | ||
"!**/node_modules/**", | ||
"!**/vendor/**" | ||
], | ||
"testRegex": "/__tests__/.*\\.spec\\.jsx?$" | ||
}, | ||
"author": "hustcc", | ||
@@ -46,0 +61,0 @@ "license": "ISC", |
@@ -1,2 +0,2 @@ | ||
# size-sensor | ||
# [size-sensor](https://git.hust.cc/size-sensor/) | ||
@@ -8,2 +8,3 @@ > DOM element size sensor which will callback when the element size changed. | ||
[![Build Status](https://github.com/hustcc/size-sensor/workflows/build/badge.svg)](https://github.com/hustcc/size-sensor/actions) | ||
[![npm](https://img.shields.io/npm/v/size-sensor.svg)](https://www.npmjs.com/package/size-sensor) | ||
@@ -96,15 +97,13 @@ [![npm](https://img.shields.io/npm/dm/size-sensor.svg)](https://www.npmjs.com/package/size-sensor) | ||
- ~~`ResizeObserver`: use [resizeObserver](src/sensors/resizeObserver.js) to observe element's size.~~ | ||
- `ResizeObserver`: use [resizeObserver](src/sensors/resizeObserver.js) to observe element's size. | ||
- `object`: use [object](src/sensors/object.js) document's resize event. | ||
~~If `ResizeObserver` exists, use it, else use `object` as default.~~ | ||
If `ResizeObserver` exists, use it, else use `object` as default. | ||
## Reference | ||
## Let me know | ||
Online demo click [here](https://git.hust.cc/size-sensor). Rewritten and optimized from [KyleAMathews/element-resize-event](https://github.com/KyleAMathews/element-resize-event). | ||
Online demo click [here](https://git.hust.cc/size-sensor). Used By: | ||
Used By: | ||
- [hustcc/echarts-for-react](https://github.com/hustcc/echarts-for-react) | ||
@@ -111,0 +110,0 @@ - [hustcc/canvas-nest.js](https://github.com/hustcc/canvas-nest.js) |
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
16191
14
354
117