{"_id":"vue3-observe-visibility2","_rev":"3-b90fab1c94c145c186ab951c2a0a2f8a","name":"vue3-observe-visibility2","dist-tags":{"latest":"0.0.3"},"versions":{"0.0.1":{"name":"vue3-observe-visibility2","description":"Detect when an element is becoming visible or hidden on the page. ","version":"0.0.1","author":{"name":"Guillaume Chau","email":"guillaume.b.chau@gmail.com"},"keywords":["vue","vuejs","plugin"],"license":"MIT","main":"dist/vue3-observe-visibility2.umd.js","module":"dist/vue3-observe-visibility2.esm.js","unpkg":"dist/vue3-observe-visibility2.min.js","scripts":{"dev":"nodemon --exec 'npm run build' --watch src","build":"npm run build:browser && npm run build:es && npm run build:umd","build:browser":"rollup --config build/rollup.config.browser.js","build:es":"rollup --config build/rollup.config.es.js","build:umd":"rollup --config build/rollup.config.umd.js","prepublishOnly":"npm run build","serve":"serve --open ./dist"},"repository":{"type":"git","url":"git+https://github.com/Akryum/vue-observe-visibility.git"},"bugs":{"url":"https://github.com/Akryum/vue-observe-visibility/issues"},"homepage":"https://github.com/Akryum/vue-observe-visibility#readme","devDependencies":{"@babel/core":"^7.4.0","@babel/plugin-transform-runtime":"^7.4.0","@babel/polyfill":"^7.4.3","@babel/preset-env":"^7.4.2","cross-env":"^5.2.0","@typescript-eslint/eslint-plugin":"^2.33.0","@typescript-eslint/parser":"^2.33.0","@vue/cli-plugin-eslint":"~4.5.0","@vue/cli-service":"^4.5.9","@vue/eslint-config-airbnb":"^5.0.2","eslint":"^6.8.0","eslint-plugin-import":"^2.20.2","eslint-plugin-vue":"^7.0.0-0","nodemon":"^1.19.0","rollup":"^1.7.0","rollup-plugin-babel":"^4.3.2","rollup-plugin-commonjs":"^9.2.1","rollup-plugin-node-resolve":"^4.0.1","rollup-plugin-replace":"^2.0.0","rollup-plugin-terser":"^4.0.4","serve":"^6.5.8"},"gitHead":"3603805945e12538374d1eda3c42e97f9d2fd2c9","_id":"vue3-observe-visibility2@0.0.1","_nodeVersion":"14.15.0","_npmVersion":"6.14.9","dist":{"integrity":"sha512-WJtX44Im41wzFm37ur81R9dLEVNibD6I/fxvYyYuIVZbb1FcGMc8DY+6x8KK4IjiROtMZHyXBEX/0vjZpesXbw==","shasum":"b192e0a58c646346f65bf7868d7f424aabdaa59d","tarball":"https://registry.npmjs.org/vue3-observe-visibility2/-/vue3-observe-visibility2-0.0.1.tgz","fileCount":27,"unpackedSize":373953,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfxlbuCRA9TVsSAnZWagAAiIkP/0SAOlpktMFIXGcLgs6r\nLPcgNQpsQq5c+2VqMZUtgk9ZHvQfOFULuvfXmAZZ0tysSLxrhoi70ShODxXG\n76KPCHXGvd501FC5EdOd1u6DehUVNbi+m55g4dzaCLZuSB3H1lSZw9sfamU+\nGYBAacVrbN/sbuXzOOsW8UTtE7LsCcbfODcDlz+QATs5yVSiB7NDCAv9Zu//\neOa2gKbYc3FB4FvqwXJR71ogbKJVWlUrmZ554XGfi+1HNb3ltoU3Ny61V3qr\nopoVg2nc0EaWhRT/NGyjBlzcB6POve6Cg9Q1W7pqUD258PdLebVWjXSDZ5fV\n5XKnIX5pFKtOYO1FZVKWbcgngJmjpEQtN3SiiSxFFuXy0QzRTsYLjzfmUv6D\n0Of+1kISCjSeYHgoscNyNFztHgVLRs8DH9FvUhiNveeqCxKgikq8jT94WCWe\nG224xUPLpF3cEqO3JiPoX+biKtimrbrkPd9827Yi+k3liGSrbOIO8urhs3N+\njf2DcCLSUmwSjEbNZyPOJs5epnFIGrg+W42/0g3ZH6fNTjvTZRaOnjTygh1H\nTclIFQlaN9h3eLeq0utqWPMG8jc6YZxBBY0w+xWOrBnqhtvbCUuLeLXYWaEO\n3ezjEweBbE+3+Frgfuw0smBWH01FZB2UJgl8u+4/U0u/jAbto7GOtCEOq3Gu\nVY47\r\n=3LSU\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIA0KGx3aUCFp50g7Y4N0ZBjijYhPNChhjS3IQAxbCFZLAiEA8znEf7N7LsCid/FJEpUt/2KDeajm3nar3W37G13q3VI="}]},"_npmUser":{"name":"yoonasy","email":"q5601990@qq.com"},"directories":{},"maintainers":[{"name":"yoonasy","email":"q5601990@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/vue3-observe-visibility2_0.0.1_1606833901573_0.19934044452896904"},"_hasShrinkwrap":false},"0.0.2":{"name":"vue3-observe-visibility2","description":"Detect when an element is becoming visible or hidden on the page. ","version":"0.0.2","author":{"name":"Guillaume Chau","email":"guillaume.b.chau@gmail.com"},"keywords":["vue","vue3","vuejs","plugin"],"license":"MIT","main":"dist/vue3-observe-visibility2.umd.js","module":"dist/vue3-observe-visibility2.esm.js","unpkg":"dist/vue3-observe-visibility2.min.js","scripts":{"dev":"nodemon --exec 'npm run build' --watch src","build":"rimraf dist/* && npm run build:browser && npm run build:es && npm run build:umd","build:browser":"rollup --config build/rollup.config.browser.js","build:es":"rollup --config build/rollup.config.es.js","build:umd":"rollup --config build/rollup.config.umd.js","prepublishOnly":"npm run build","serve":"serve --open ./dist"},"repository":{"type":"git","url":"git+https://github.com/Akryum/vue-observe-visibility.git"},"bugs":{"url":"https://github.com/Akryum/vue-observe-visibility/issues"},"homepage":"https://github.com/Akryum/vue-observe-visibility#readme","peerDependencies":{"vue":"^3.0.0"},"devDependencies":{"@babel/core":"^7.4.0","@babel/plugin-transform-runtime":"^7.4.0","@babel/polyfill":"^7.4.3","@babel/preset-env":"^7.4.2","cross-env":"^5.2.0","@typescript-eslint/eslint-plugin":"^2.33.0","@typescript-eslint/parser":"^2.33.0","@vue/cli-plugin-eslint":"~4.5.0","@vue/cli-service":"^4.5.9","@vue/eslint-config-airbnb":"^5.0.2","eslint":"^6.8.0","eslint-plugin-import":"^2.20.2","eslint-plugin-vue":"^7.0.0-0","nodemon":"^1.19.0","rollup":"^1.7.0","rollup-plugin-babel":"^4.3.2","rollup-plugin-commonjs":"^9.2.1","rollup-plugin-json":"^4.0.0","rollup-plugin-node-resolve":"^4.0.1","rollup-plugin-replace":"^2.0.0","rollup-plugin-terser":"^4.0.4","serve":"^6.5.8"},"gitHead":"abc1bc1f8aa58483a7a430aaec9bc344c0f620e4","_id":"vue3-observe-visibility2@0.0.2","_nodeVersion":"14.15.0","_npmVersion":"6.14.9","dist":{"integrity":"sha512-a0xZnyMZQMQZu5bO/+0wbQ8+XxC7T7v+jdnA5SPHt1tlHEtuhHmWUEmv5Usm4qAMguLBso2ykSVxh6g/SUS+CQ==","shasum":"dfa9eca0e1231b698f745273d4d88957b54c1807","tarball":"https://registry.npmjs.org/vue3-observe-visibility2/-/vue3-observe-visibility2-0.0.2.tgz","fileCount":5,"unpackedSize":26752,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfx4OmCRA9TVsSAnZWagAA1hsP/0Z05DAOwk8IrKAgwFcO\nvZuo1cKMiqjf1Uk/k16OVjeKOutpVKE2AtqUfEgUPbJyW5x/Zb4Jr6Lt62eg\nwYtR1sAekxXPqkxxnNem9WIxU/sg9kYeLARDBNZGYJDOBLJLuAkzoR+6SmQK\n2tZh5dF0PLHdRwLKuXhjHr8DShkm5jxw3couN7M7Gta4KL47K/JRLNWGiHRb\nNJbnFoepUxgYnv9rWIa3ZIh6puqt/WawM1a0oyke3qUgVuReIM+vnsufnj+u\n+ZogAG1V9GA9ieYPzHrAksXKsTDicEe65prPhUaELMFWAVcUh+bcZWXtdhxJ\nL4gFfUo7Hl3fk6UwsLlCjvJ+HhcmccN1PGL9ZT1Qg4lpkU/4svI35g2Xki2n\nNc7gxy4cuurs+2ZovdBbtd8zdkFeZ4r480jItkqFtTXekcLGyEZywXTKnrUd\nKvXUE8T0Y4ucUWxn1QkJHGVFeKShwxc+Gq0IMWB8S9UAMpKLzIGt8PIrD182\nTUVfbMZHEnnT/lKGlE1XyTgkb3I+5rHY3N6WUBS7MbUSyb2hcnq/j06IH+Jq\nnVm/MA7qbhlmCp7HX+c9fHHg/K/y5iMoMri3F3wnOlrBLs/d67UQaGPosELT\nnttYrzT9hpBfhmkIo7luMmRqH+ScP0lpKMVim7yWIWQawGlNe7lwHAVAxH7K\nBQtF\r\n=ARHm\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD8afDroDgfy2T0OAY4dpJ3PvFefxSkAdwfsdrsllZJgQIgVGnGlE4nc8C2ffo08kcNcYzzGjlYci8uakxNovsUins="}]},"_npmUser":{"name":"yoonasy","email":"q5601990@qq.com"},"directories":{},"maintainers":[{"name":"yoonasy","email":"q5601990@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/vue3-observe-visibility2_0.0.2_1606910886128_0.666728992761332"},"_hasShrinkwrap":false},"0.0.3":{"name":"vue3-observe-visibility2","description":"Detect when an element is becoming visible or hidden on the page. ","version":"0.0.3","author":{"name":"Guillaume Chau","email":"guillaume.b.chau@gmail.com"},"keywords":["vue","vue3","vuejs","plugin"],"license":"MIT","main":"dist/vue3-observe-visibility2.umd.js","module":"dist/vue3-observe-visibility2.esm.js","unpkg":"dist/vue3-observe-visibility2.min.js","scripts":{"dev":"nodemon --exec 'npm run build' --watch src","build":"rimraf dist/* && npm run build:browser && npm run build:es && npm run build:umd","build:browser":"rollup --config build/rollup.config.browser.js","build:es":"rollup --config build/rollup.config.es.js","build:umd":"rollup --config build/rollup.config.umd.js","prepublishOnly":"npm run build","serve":"serve --open ./dist"},"repository":{"type":"git","url":"git+https://github.com/Akryum/vue-observe-visibility.git"},"bugs":{"url":"https://github.com/Akryum/vue-observe-visibility/issues"},"homepage":"https://github.com/Akryum/vue-observe-visibility#readme","peerDependencies":{"vue":"^3.0.0"},"devDependencies":{"@babel/core":"^7.4.0","@babel/plugin-transform-runtime":"^7.4.0","@babel/polyfill":"^7.4.3","@babel/preset-env":"^7.4.2","cross-env":"^5.2.0","@typescript-eslint/eslint-plugin":"^2.33.0","@typescript-eslint/parser":"^2.33.0","@vue/cli-plugin-eslint":"~4.5.0","@vue/cli-service":"^4.5.9","@vue/eslint-config-airbnb":"^5.0.2","eslint":"^6.8.0","eslint-plugin-import":"^2.20.2","eslint-plugin-vue":"^7.0.0-0","nodemon":"^1.19.0","rollup":"^1.7.0","rollup-plugin-babel":"^4.3.2","rollup-plugin-commonjs":"^9.2.1","rollup-plugin-json":"^4.0.0","rollup-plugin-node-resolve":"^4.0.1","rollup-plugin-replace":"^2.0.0","rollup-plugin-terser":"^4.0.4","serve":"^6.5.8"},"gitHead":"99aeb6992a9d1ac84cd40b51b1d5a37e608ad41a","_id":"vue3-observe-visibility2@0.0.3","_nodeVersion":"14.15.0","_npmVersion":"6.14.9","dist":{"integrity":"sha512-yJL0G5RrI/uXdDrs+0fdlk/dYKhKBRZtkwJO0ar44NTIX+Rnw63iHgTz+p00M+yp6Avm1Q+o6y82h0hkTzmpHg==","shasum":"de8b494dd9002d815dab455ab859306a08c3a6a7","tarball":"https://registry.npmjs.org/vue3-observe-visibility2/-/vue3-observe-visibility2-0.0.3.tgz","fileCount":5,"unpackedSize":26714,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfx50qCRA9TVsSAnZWagAAwaYP/3rMZYH+rj1LvMI63SKb\n3J2AdKoCConxwgtWSvtw+Wr1hV0Gjc6x2pGXjb+wrhg1be9KFo/2vUBz20We\njlES6x5sOU6kppLGOcUbSK1hUTURZrXPc4Bt0yC7uiwddGhIIQ580S+YtTlk\nlEzTGk/L8IMs9+0dDiC3MzZHk/1VMzosSB3xqYZQt1ngzmmH/Fty0qeYY5/0\nGr7HthtFdWDDEvKs+FT6weRhh7HaiXkqr+WHCp5/UVGp+r9O2tFtK0M7oTbu\nzgFkrDtTcWVQpHbXMwGxeHSvw6s1jhzqE8RNi3B2PIlfMPC6Z1hxcFOIQqL+\nb1LSLuTxUmJFwXUbg2/zgqe1W4MYKBi9L/LG/RuYUWG8IpkCe+wIv+iiqzDp\nYKawDYAjz73u755g/48i9WO5Tew59xgW80N2skKTU1bhbwdQ6n6dTuX6SPiC\ns1nXrRlxo2r8JvwQLqJs3GJ3PuWYoXVnw4hdRLx9j1TIMWtRhTsY3sMEW5a3\n7iDb8itGROQnSGhVcVlaPV+RNpVGhpoAZe1Jwiw0zuTVGFa1HnLZoumidAgh\nDATt5rfLIlHkdeptOE+rzFoCM7JEOq0nBi49lgXJTBrY4uJ0/7CaVNteD5fu\nfp64XrhnbNAbSmJSTEyd9JvOs7KoClgRSzavd/C6K7VhaM79qGYXhSzsKYO5\nt+ZC\r\n=Ltvo\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC5EI4Zegy6m40YH5Xc2Lwx2fTH7RQ4MdJLML+yZQybVwIhAKg8jlj8doQElzIZ5PH3azLdByv9YBJ4EypG9Cy6kUFE"}]},"_npmUser":{"name":"yoonasy","email":"q5601990@qq.com"},"directories":{},"maintainers":[{"name":"yoonasy","email":"q5601990@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/vue3-observe-visibility2_0.0.3_1606917418371_0.07613703968664831"},"_hasShrinkwrap":false}},"time":{"created":"2020-12-01T14:45:01.571Z","0.0.1":"2020-12-01T14:45:01.843Z","modified":"2022-05-23T21:19:31.621Z","0.0.2":"2020-12-02T12:08:06.262Z","0.0.3":"2020-12-02T13:56:58.515Z"},"maintainers":[{"name":"yoonasy","email":"q5601990@qq.com"}],"description":"Detect when an element is becoming visible or hidden on the page. ","homepage":"https://github.com/Akryum/vue-observe-visibility#readme","keywords":["vue","vue3","vuejs","plugin"],"repository":{"type":"git","url":"git+https://github.com/Akryum/vue-observe-visibility.git"},"author":{"name":"Guillaume Chau","email":"guillaume.b.chau@gmail.com"},"bugs":{"url":"https://github.com/Akryum/vue-observe-visibility/issues"},"license":"MIT","readme":"<p align=\"center\">\n<img src=\"./logo.png\" alt=\"vue3-observe-visibility2 logo\"/>\n</p>\n\n<h1 align=\"center\">vue3-observe-visibility2</h1>\n\n<p align=\"center\">\n<a href=\"https://www.npmjs.com/package/vue3-observe-visibility2\"><img src=\"https://img.shields.io/npm/v/vue3-observe-visibility2.svg\"/> <img src=\"https://img.shields.io/npm/dm/vue3-observe-visibility2.svg\"/></a> <a href=\"https://vuejs.org/\"><img src=\"https://img.shields.io/badge/vue-3.x-brightgreen.svg\"/></a>\n</p>\n\n<p align=\"center\">\nDetect when an element is becoming visible or hidden on the page. <a href=\"https://jsfiddle.net/Akryum/ppt7endj/\">Demo</a>\n</p>\n\n<p align=\"center\">\n  <a href=\"https://www.patreon.com/akryum\" target=\"_blank\">\n    <img src=\"https://c5.patreon.com/external/logo/become_a_patron_button.png\" alt=\"Become a Patreon\">\n  </a>\n</p>\n\n## Sponsors\n\n[![sponsors logos](https://guillaume-chau.info/sponsors.png)](https://guillaume-chau.info/sponsors)\n\n<br>\n\n## Table of contents\n\n- [Installation](#installation)\n- [Usage](#usage)\n- [Example](#example)\n\n# Installation\n\n```\nnpm install --save vue-observe-visibility\n```\n\n**⚠️ This plugin uses the [Intersection Observer API](http://caniuse.com/#feat=intersectionobserver) that is not supported in every browser (currently supported in Edge, Firefox and Chrome). You need to include a [polyfill](https://github.com/w3c/IntersectionObserver/tree/master/polyfill) to make it work on incompatible browsers.**\n\n## Import\n\n```javascript\nimport VueObserveVisibility from 'vue-observe-visibility'\n\napp.use(VueObserveVisibility)\n```\n\nOr:\n\n```javascript\nimport { ObserveVisibility } from 'vue-observe-visibility'\n\napp.directive('observe-visibility', ObserveVisibility)\n```\n\n## Browser\n\n```html\n<script src=\"vue.js\"></script>\n<script src=\"https://unpkg.com/vue-observe-visibility/dist/vue-observe-visibility.min.js\"></script>\n```\n\nThe plugin should be auto-installed. If not, you can install it manually with the instructions below.\n\nInstall all the directives:\n\n```javascript\nVue.use(VueObserveVisibility)\n```\n\nUse specific directives:\n\n```javascript\napp.directive('observe-visibility', VueObserveVisibility.ObserveVisibility)\n```\n\n# Usage\n\nThe `v-observe-visibility` directive is very easy to use. Just pass a function as the value:\n\n```html\n<div v-observe-visibility=\"visibilityChanged\">\n```\n\nThis also works on components:\n\n```html\n<MyComponent v-observe-visibility=\"visibilityChanged\" />\n```\n\nThe function will be called whenever the visiblity of the element changes with the argument being a boolean (`true` means the element is visible on the page, `false` means that it is not).\n\nThe second argument is the corresponding [IntersectionObserverEntry](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserverEntry) object.\n\n```javascript\nvisibilityChanged (isVisible, entry) {\n  this.isVisible = isVisible\n  console.log(entry)\n}\n```\n\n## IntersectionObserver options\n\nIt's possible to pass the [IntersectionObserver `options` object](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/IntersectionObserver#Parameters) using the `intersection` attribute:\n\n```html\n<div v-observe-visibility=\"{\n  callback: visibilityChanged,\n  intersection: {\n    root: ...,\n    rootMargin: ...,\n    threshold: 0.3,\n  },\n}\">\n```\n\n## Once\n\nIt can be useful to listen for when the element is visible only once, for example to build introduction animations. Set the `once` option to `true`:\n\n```html\n<div v-observe-visibility=\"{\n  callback: visibilityChanged,\n  once: true,\n}\">\n```\n\n## Throttling visibility\n\nYou can use the `throttle` options (in ms) specifying minimal state duration after which an event will be fired. It's useful when you are tracking visibility while scrolling and don't want events from fastly scrolled out elements.\n\n```html\n<div v-observe-visibility=\"{\n  callback: visibilityChanged,\n  throttle: 300,\n}\">\n```\n\nYou can also pass a `leading` option to trigger the callback the first time when the visibility changes without waiting for the throttle delay.\nI can either be `visible`, `hidden` or `both`.\n\n```html\n<div v-observe-visibility=\"{\n  callback: visibilityChanged,\n  throttle: 300,\n  throttleOptions: {\n    leading: 'visible',\n  },\n}\">\n```\n\n## Passing custom arguments\n\nYou can add custom argument by using an intermediate function:\n\n```html\n<div v-observe-visibility=\"(isVisible, entry) => visibilityChanged(isVisible, entry, customArgument)\">\n```\n\nHere `visibilityChanged` will be call with a third custom argument `customArgument`.\n\n## Disabling the observer\n\nPassing a falsy value to the directive will disable the observer:\n\n```html\n<div\n  v-for=\"(item, index) of items\"\n  :key=\"item.id\"\n  v-observe-visibility=\"index === items.length - 1 ? visibilityChanged : false\"\n>\n```\n\n# Example\n\n```html\n<div id=\"app\">\n  <button @click=\"show = !show\">Toggle</button>\n  <label>\n    <input type=\"checkbox\" v-model=\"isVisible\" disabled/> Is visible?\n  </label>\n  <div ref=\"test\" v-show=\"show\" v-observe-visibility=\"visibilityChanged\">Hello world!</div>\n</div>\n\n<script>\nnew Vue({\n  el: '#app',\n  data: {\n    show: true,\n    isVisible: true,\n  },\n  methods: {\n    visibilityChanged (isVisible, entry) {\n      this.isVisible = isVisible\n      console.log(entry)\n    },\n  },\n})\n</script>\n```\n\n---\n\n## License\n\n[MIT](http://opensource.org/licenses/MIT)\n","readmeFilename":"README.md"}