{"name":"size-sensor","version":"0.2.3","description":"DOM element size sensor which will callback when size changed.","main":"lib/index.js","types":"index.d.ts","scripts":{"coveralls":"cat ./coverage/lcov.info | coveralls","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":"^6.26.0","babel-plugin-add-module-exports":"^0.2.1","babel-plugin-version":"^0.2.1","babel-preset-env":"^1.6.1","cross-env":"^5.1.3","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","size-limit":"^0.18.2"},"author":{"name":"hustcc"},"license":"ISC","bugs":{"url":"https://github.com/hustcc/size-sensor/issues"},"homepage":"https://git.hust.cc/size-sensor","gitHead":"d0e29f37b19fe922fc700058f9f462f9489cd540","_id":"size-sensor@0.2.3","_npmVersion":"6.4.1","_nodeVersion":"10.10.0","_npmUser":{"name":"atool","email":"i@hust.cc"},"dist":{"integrity":"sha512-o64ObtSk+KlYmsRtiUYGP46peaOfCDWZUP7XAmkgAHbDa1do8zudxlVNkmCBfp/pRZa/D6xmcdn7c8rjbQiRhQ==","shasum":"663876417d302a28490b4979095681fb827f1949","tarball":"http://registry-npm.ywwl.com/size-sensor/download/size-sensor-0.2.3.tgz","fileCount":13,"unpackedSize":15047,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcuSi0CRA9TVsSAnZWagAAnJIP/RLVlXfc8AiTf2JUMB6C\nzt8nGZNNNe0py0v4NZ6VNkK2/VYHb94lYsSu1M/trGfaebc1e45J/x4SneJP\nKOdX5564ArLioBm9NwwhIdT+E8qcxu5+f0g46ArQeqSjp6DCPsagKR95fNEe\njGTXUgvU1vuR6R3eMGthEXFCkUOUX/fyOr0XGzBk+C+/Eq2LTkfV04JExBaU\nZT94sKGICyPia2HJuDs1qjP50+hgJa7X5Z6x2M4PfzJDA5kWjJy1k8alp7XQ\nY6RZQxL3EXsQCoNZE+kA/RSM5wnJDXeXH3ui5BV7bergD2XstzKhJf39NA9o\nptFLIhDXWO6COJoGJrFkasaXBtT4u3aiQjxM/rEiYYtOsaMGspWLy9GxZ2kQ\nSQagAXjbTIJJigROrRqIa0qFJpRk+1xnm0O47jfZBpDyPcBXvkW8JC49X4Gq\nyHOm0aXIn7rp5YfVRqntqQCfG1w/LeGv06TGQzNuqJwXGhFHx2BwgBILHbbc\n+cQhpz8L6C/Uj1l9B/08EEHA/mzswrmI5vfIegcZWpJjRcrVz2TUtqVfwdZM\nUnhdJ2fGXwyrmpNxObeGKAr9BG6E1m/57++FdXNIlqHfYBVeYJ86H502zp1L\n5OeCEMWd48p43xFIgZoi3IU/b+ljioFHrzVU0IXCkEPPjXE1JzF5F91WbSLt\njIvM\r\n=0JAi\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDu4vfYZ6WZkBvpZfXxqQJ8Xe4fJhvt/IdaBKXgN2p4SgIgKUgIr3XHyISRtfyj4ZZBS6HlvFxAjFsZkWAUUODklIM="}],"size":5060,"noattachment":false,"key":"/size-sensor/-/size-sensor-0.2.3.tgz"},"maintainers":[{"name":"atool","email":"vip@hust.edu.cn"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/size-sensor_0.2.3_1555638451748_0.4855879840734658"},"_hasShrinkwrap":false,"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 - [antvis/G2Plot](https://github.com/antvis/G2Plot)\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\n\n\n# License\n\n\nISC@[hustcc](https://github.com/hustcc).\n","publish_time":1555638451898,"_cnpm_publish_time":1555638451898,"dist-tags":{"latest":"1.0.3"}}