{"id":30071377,"url":"https://github.com/opuu/inview-vue","last_synced_at":"2026-05-10T16:05:33.910Z","repository":{"id":307585257,"uuid":"1030022366","full_name":"opuu/inview-vue","owner":"opuu","description":"Check if an element is visible in the viewport using Vue 3 directives.","archived":false,"fork":false,"pushed_at":"2025-08-01T01:20:34.000Z","size":38,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-08-01T02:56:47.178Z","etag":null,"topics":["aos","infinite-scroll","inview","inviewport","lazy-loading","vue","vue-directive","vue-directives","vue-inview","vue3","vuejs"],"latest_commit_sha":null,"homepage":"https://opuu.github.io/inview/demo/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/opuu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-08-01T01:02:52.000Z","updated_at":"2025-08-01T01:20:38.000Z","dependencies_parsed_at":"2025-08-01T02:56:49.287Z","dependency_job_id":"894a4455-62bd-47fc-8ebd-90e2b182d770","html_url":"https://github.com/opuu/inview-vue","commit_stats":null,"previous_names":["opuu/inview-vue"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/opuu/inview-vue","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opuu%2Finview-vue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opuu%2Finview-vue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opuu%2Finview-vue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opuu%2Finview-vue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/opuu","download_url":"https://codeload.github.com/opuu/inview-vue/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opuu%2Finview-vue/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269423853,"owners_count":24414615,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-08T02:00:09.200Z","response_time":72,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aos","infinite-scroll","inview","inviewport","lazy-loading","vue","vue-directive","vue-directives","vue-inview","vue3","vuejs"],"created_at":"2025-08-08T12:42:24.641Z","updated_at":"2026-05-10T16:05:28.843Z","avatar_url":"https://github.com/opuu.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# InView Vue\n\nVue 3 directives for viewport detection. Simple `v-inview` and `v-outview` directives.\n\n[![npm version](https://badge.fury.io/js/%40opuu%2Finview-vue.svg)](https://badge.fury.io/js/%40opuu%2Finview-vue)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n## Installation\n\n```bash\nnpm install @opuu/inview-vue\n```\n\n## Setup\n\n```javascript\n// main.js\nimport { createApp } from \"vue\";\nimport { createInViewDirective, createOutViewDirective } from \"@opuu/inview-vue\";\n\nconst app = createApp(App);\n\napp.directive(\"inview\", createInViewDirective());\napp.directive(\"outview\", createOutViewDirective());\n\napp.mount(\"#app\");\n```\n\n## Usage\n\n```vue\n\u003ctemplate\u003e\n\t\u003c!-- Enter viewport --\u003e\n\t\u003cdiv v-inview=\"handleEnter\"\u003eI'm visible!\u003c/div\u003e\n\n\t\u003c!-- Exit viewport --\u003e\n\t\u003cdiv v-outview=\"handleExit\"\u003eI'm hidden!\u003c/div\u003e\n\n\t\u003c!-- Both --\u003e\n\t\u003cdiv v-inview=\"onEnter\" v-outview=\"onExit\"\u003eTrack both\u003c/div\u003e\n\u003c/template\u003e\n\n\u003cscript setup\u003e\nfunction handleEnter(event) {\n\tconsole.log(\"Visible:\", event.percentage + \"%\");\n}\n\nfunction handleExit(event) {\n\tconsole.log(\"Hidden\");\n}\n\nfunction onEnter(event) {\n\tevent.target.classList.add(\"visible\");\n}\n\nfunction onExit(event) {\n\tevent.target.classList.remove(\"visible\");\n}\n\u003c/script\u003e\n```\n\n## Examples\n\n### Lazy Loading\n\n```vue\n\u003ctemplate\u003e\n\t\u003cimg v-for=\"image in images\" :key=\"image.id\" v-inview=\"lazyLoad\" :data-src=\"image.src\" src=\"placeholder.jpg\" /\u003e\n\u003c/template\u003e\n\n\u003cscript setup\u003e\nfunction lazyLoad(event) {\n\tconst img = event.target;\n\timg.src = img.dataset.src;\n}\n\u003c/script\u003e\n```\n\n### Animations\n\n```vue\n\u003ctemplate\u003e\n\t\u003cdiv v-inview=\"fadeIn\" v-outview=\"fadeOut\" class=\"box\"\u003eAnimate me!\u003c/div\u003e\n\u003c/template\u003e\n\n\u003cscript setup\u003e\nfunction fadeIn(event) {\n\tevent.target.classList.add(\"animate\");\n}\n\nfunction fadeOut(event) {\n\tevent.target.classList.remove(\"animate\");\n}\n\u003c/script\u003e\n\n\u003cstyle\u003e\n.box {\n\topacity: 0;\n\ttransition: opacity 0.3s;\n}\n.box.animate {\n\topacity: 1;\n}\n\u003c/style\u003e\n```\n\n### Analytics\n\n```vue\n\u003ctemplate\u003e\n\t\u003csection v-inview=\"trackView\" data-section=\"hero\"\u003eHero content\u003c/section\u003e\n\u003c/template\u003e\n\n\u003cscript setup\u003e\nfunction trackView(event) {\n\tif (event.percentage \u003e 50) {\n\t\tanalytics.track(\"section_viewed\", {\n\t\t\tsection: event.target.dataset.section,\n\t\t});\n\t}\n}\n\u003c/script\u003e\n```\n\n## Configuration\n\nYou can configure directives globally:\n\n```javascript\nimport { createInViewDirective } from \"@opuu/inview-vue\";\n\napp.directive(\n\t\"inview\",\n\tcreateInViewDirective({\n\t\tdelay: 100, // Debounce delay in ms\n\t\tprecision: \"high\", // \"low\", \"medium\", or \"high\"\n\t})\n);\n```\n\n| Option      | Default    | Description                    |\n| ----------- | ---------- | ------------------------------ |\n| `delay`     | `0`        | Debounce delay in milliseconds |\n| `precision` | `\"medium\"` | Observation precision level    |\n\n## Local Registration\n\n```vue\n\u003ctemplate\u003e\n\t\u003cdiv v-inview=\"handleEnter\"\u003eLocal directive\u003c/div\u003e\n\u003c/template\u003e\n\n\u003cscript setup\u003e\nimport { createInViewDirective } from \"@opuu/inview-vue\";\n\nconst vInview = createInViewDirective({ delay: 200 });\n\nfunction handleEnter(event) {\n\tconsole.log(\"Triggered:\", event.percentage);\n}\n\u003c/script\u003e\n```\n\n## TypeScript\n\n```vue\n\u003cscript setup lang=\"ts\"\u003e\nimport type { InViewEvent } from \"@opuu/inview-vue\";\n\nfunction handleEnter(event: InViewEvent): void {\n\tconsole.log(`Element is ${event.percentage}% visible`);\n}\n\u003c/script\u003e\n```\n\n## Nuxt.js\n\nCreate a plugin:\n\n```javascript\n// plugins/inview.js\nimport { createInViewDirective, createOutViewDirective } from \"@opuu/inview-vue\";\n\nexport default defineNuxtPlugin((nuxtApp) =\u003e {\n\tnuxtApp.vueApp.directive(\"inview\", createInViewDirective());\n\tnuxtApp.vueApp.directive(\"outview\", createOutViewDirective());\n});\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopuu%2Finview-vue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopuu%2Finview-vue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopuu%2Finview-vue/lists"}