{"name":"size-sensor","version":"0.2.6","description":"DOM element size sensor which will callback when size changed.","main":"lib/index.js","types":"index.d.ts","scripts":{"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","build:lib":"rimraf ./lib && cross-env NODE_ENV=babel babel src -d lib","build":"npm run build:umd && npm run build:lib && size-limit"},"size-limit":[{"limit":"1 KB","path":"dist/size-sensor.min.js"}],"repository":{"type":"git","url":"git+https://github.com/hustcc/size-sensor.git"},"keywords":["resize","size","sensor","size-detector","element"],"devDependencies":{"@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","cross-env":"^5.1.3","jest":"^24.9.0","jest-electron":"^0.1.6","rimraf":"^2.6.2","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":{"name":"hustcc"},"license":"ISC","bugs":{"url":"https://github.com/hustcc/size-sensor/issues"},"homepage":"https://git.hust.cc/size-sensor","readme":"# [size-sensor](https://git.hust.cc/size-sensor/)\n\n> DOM element size sensor which will callback when the element size changed.\n>\n> DOM 元素尺寸监听器，当元素尺寸变化的时候，将会触发回调函数！\n\n\n[![Build Status](https://github.com/hustcc/size-sensor/workflows/build/badge.svg)](https://github.com/hustcc/size-sensor/actions)\n[![npm](https://img.shields.io/npm/v/size-sensor.svg)](https://www.npmjs.com/package/size-sensor)\n[![npm](https://img.shields.io/npm/dm/size-sensor.svg)](https://www.npmjs.com/package/size-sensor)\n[![gzip](http://img.badgesize.io/https://unpkg.com/size-sensor/dist/size-sensor.min.js?compression=gzip)](https://unpkg.com/size-sensor/dist/size-sensor.min.js)\n\n - [rc-size-sensor](https://www.npmjs.com/package/rc-size-sensor): React component wrapper.\n\n\n\n## Install\n\n\n> npm i --save size-sensor\n\nThen import it.\n\n```js\nimport { bind, clear } from 'size-sensor';\n```\n\nor import it by `script` in HTML, then get `sizeSensor` on window.\n\n```html\n<script src=\"https://unpkg.com/size-sensor/dist/size-sensor.min.js\"></script>\n```\n\n\n\n## Usage\n\n\n - **bind & unbind**\n\n```js\nimport { bind, clear } from 'size-sensor';\n\n// bind the event on element, will get the `unbind` function\nconst unbind1 = bind(document.querySelector('.container'), element => {\n  // do what you want to to.\n});\n\nconst unbind2 = bind(document.querySelector('.container'), element => {\n  // do what you want to to.\n});\n\n// if you want to cancel bind event.\nunbind1();\n```\n\n\n - **clear**\n\n```js\nimport { bind, clear } from 'size-sensor';\n\n/*\n * // bind the resize event.\n * const unbind1 = bind(...);\n * const unbind2 = bind(...);\n * ...\n */\n\n// you can cancel all the event of element.\nclear(element);\n```\n\n\n\n## API\n\n\nThere is only 2 API:\n\n\n - **bind(element, callback)**\n\nBind the resize trigger function on element. The function will return `unbind` function.\n\n - **clear(element)**\n\nClear all the object and resize event on element.\n\n\n\n## Strategies\n\nThe size sensor strategies include:\n\n - `ResizeObserver`: use [resizeObserver](src/sensors/resizeObserver.js) to observe element's size.\n - `object`: use [object](src/sensors/object.js) document's resize event.\n\nIf `ResizeObserver` exists, use it, else use `object` as default.\n\n\n\n## Let me know\n\nOnline demo click [here](https://git.hust.cc/size-sensor). Used By:\n\n - [hustcc/echarts-for-react](https://github.com/hustcc/echarts-for-react)\n - [hustcc/canvas-nest.js](https://github.com/hustcc/canvas-nest.js)\n - [hustcc/gantt-for-react](https://github.com/hustcc/gantt-for-react)\n\n\n\n# License\n\n\nISC@[hustcc](https://github.com/hustcc).\n","readmeFilename":"README.md","gitHead":"3b467effa99c4dd06a904db2a28454a83e00a3de","_id":"size-sensor@0.2.6","_nodeVersion":"11.12.0","_npmVersion":"6.7.0","dist":{"integrity":"sha512-0EZ0tXXjyRl9R9+JpoBdH57Xpnbf5NTyDdj7fnFL6KqCsdKyah286ShMflnV2SonnrSFH4OAT/52Jy8qqnoerg==","shasum":"6fe43afd570786f097171834002a97fe0b19a3da","tarball":"http://registry-npm.ywwl.com/size-sensor/download/size-sensor-0.2.6.tgz","fileCount":13,"unpackedSize":16191,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdyjz3CRA9TVsSAnZWagAAkbYP/1apDear0c+HW+CHdPWt\nlVhNNuiNyYVsuv1Lsg7kZIvyBRe6Tf74G37w/8O4GlyMM5ZDXOOOxoj10qZC\nzneXT+xStVvPwjEaAeODclrt/FW2I3BwwonvHMSLDq7CvUOfejxNCRmFBQ8W\nt/CEZJnC6e8qIWQhQ83uQHbt78CmiK+3R6NRosPUyaxGgpoVGPlG9c0OeOzb\nKMbZOiwV3ZH2wUB9GedADMOys+FUJUAoeEjsadKiNRq6vqxx5Y3AjK6yvW/l\nDzT/Bsq/0MInJReLtaAf7YuCpEepLPO8ykwuj7FqkYs4txGerkAtotnH9okR\nfUsSpeciNAvzQP3kxXNSzM00eFSLQUzMtUWV6vWRJP2scJG+QGSwJLzSp14j\neTEF5zYUF1d6V9QzWr6pK2zbRqQcfA8jmlnj8q69/a7obsTh+sB3GrwPrScw\nWZVEiZ7Ummq1iuNLgOEJemehU0utPY36tLjbo1eUAXQTuZeh+b+TlJAfSomt\n7H/o941JjFMPJN8uZsa64oLeDlQ91hWPiVyhkacgBq6T1lniLPQa9LHAYbBD\nGSPr1Kf/Uo70dphoGORxGedM9pnbYVg85+zvA38g2n12PjySHY+i6x6cTBtA\n4MPLbMfgTBYRjJ976Ou+LE7e5xFMToPz17pNMS6RAIz9TWB3wf9HdqBrat/o\nGmXh\r\n=5x31\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGj/DxJAAYHeWZjObfLOBoAeR24N0gMOvYj+X0gnUNqJAiEA6YyUKiuZdK/7Vhb/l67QVxJSa5oUdXu5o/4KOh9h5mw="}],"size":5167,"noattachment":false,"key":"/size-sensor/-/size-sensor-0.2.6.tgz"},"maintainers":[{"name":"atool","email":"vip@hust.edu.cn"}],"_npmUser":{"name":"atool","email":"i@hust.cc"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/size-sensor_0.2.6_1573534966568_0.754176761768933"},"_hasShrinkwrap":false,"publish_time":1573534966693,"_cnpm_publish_time":1573534966693,"dist-tags":{"latest":"1.0.3"}}