{"id":13437999,"url":"https://github.com/camwiegert/in-view","last_synced_at":"2025-09-28T19:31:14.084Z","repository":{"id":40633349,"uuid":"64762103","full_name":"camwiegert/in-view","owner":"camwiegert","description":"Get notified when a DOM element enters or exits the viewport. :eyes:","archived":true,"fork":false,"pushed_at":"2019-10-27T19:45:24.000Z","size":147,"stargazers_count":4633,"open_issues_count":0,"forks_count":231,"subscribers_count":86,"default_branch":"master","last_synced_at":"2025-09-20T21:46:37.321Z","etag":null,"topics":["javascript","utility","viewport"],"latest_commit_sha":null,"homepage":"https://camwiegert.github.io/in-view","language":"JavaScript","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/camwiegert.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-08-02T14:06:34.000Z","updated_at":"2025-07-28T09:09:44.000Z","dependencies_parsed_at":"2022-07-14T04:20:31.505Z","dependency_job_id":null,"html_url":"https://github.com/camwiegert/in-view","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/camwiegert/in-view","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/camwiegert%2Fin-view","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/camwiegert%2Fin-view/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/camwiegert%2Fin-view/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/camwiegert%2Fin-view/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/camwiegert","download_url":"https://codeload.github.com/camwiegert/in-view/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/camwiegert%2Fin-view/sbom","scorecard":{"id":264069,"data":{"date":"2025-08-11","repo":{"name":"github.com/camwiegert/in-view","commit":"b6389d348df8b172c80f48ab554086333afcf03a"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.3,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 2/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"project is archived","details":["Warn: Repository is archived."],"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":-1,"reason":"internal error: internal error: Client.Checks.ListCheckRunsForRef: error during graphqlHandler.setupCheckRuns: non-200 OK status code: 502 Bad Gateway body: \"\u003chtml\u003e\\r\\n\u003chead\u003e\u003ctitle\u003e502 Bad Gateway\u003c/title\u003e\u003c/head\u003e\\r\\n\u003cbody\u003e\\r\\n\u003ccenter\u003e\u003ch1\u003e502 Bad Gateway\u003c/h1\u003e\u003c/center\u003e\\r\\n\u003chr\u003e\u003ccenter\u003enginx\u003c/center\u003e\\r\\n\u003c/body\u003e\\r\\n\u003c/html\u003e\\r\\n\"","details":null,"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-17T11:31:27.862Z","repository_id":40633349,"created_at":"2025-08-17T11:31:27.862Z","updated_at":"2025-08-17T11:31:27.862Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276613251,"owners_count":25673398,"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-09-23T02:00:09.130Z","response_time":73,"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":["javascript","utility","viewport"],"created_at":"2024-07-31T03:01:02.043Z","updated_at":"2025-09-28T19:31:13.825Z","avatar_url":"https://github.com/camwiegert.png","language":"JavaScript","readme":"# in-view.js :eyes:\n\nGet notified when a DOM element enters or exits the viewport. A small (~1.9kb gzipped), dependency-free, javascript utility for IE9+.\n\n[camwiegert.github.io/in-view](https://camwiegert.github.io/in-view)\n\n[![Build Status](https://travis-ci.org/camwiegert/in-view.svg?branch=master)](https://travis-ci.org/camwiegert/in-view)\n[![npm/in-view](https://img.shields.io/npm/v/in-view.svg?maxAge=2592000)](https://npmjs.com/package/in-view)\n\n![in-view.js](https://camwiegert.github.io/in-view/lib/images/in-view.png)\n\n---\n\n## Installation\n\nEither download the [latest release](https://unpkg.com/in-view/dist/in-view.min.js) and include it in your markup or install with [npm](http://npmjs.com/package/in-view):\n\n```sh\nnpm install --save in-view\n```\n\n---\n\n## Basic Usage\n\nWith in-view, you can register handlers that are called when an element **enters** or **exits** the viewport. Each handler receives one element, the one entering or exiting the viewport, as its only argument.\n\n```js\ninView('.someSelector')\n    .on('enter', doSomething)\n    .on('exit', el =\u003e {\n        el.style.opacity = 0.5;\n    });\n```\n\n---\n\n## API\n\nin-view maintains a separate handler registry for each set of elements captured with `inView(\u003cselector\u003e)`. Each registry exposes the same four methods. in-view also exposes four top-level methods. (`is`, `offset`, `threshold`, `test`).\n\n### inView(\\\u003cselector\u003e).on(\\\u003cevent\u003e, \\\u003chandler\u003e)\n\u003e Register a handler to the elements selected by `selector` for `event`. The only events in-view emits are `'enter'` and `'exit'`.\n\n\u003e ```js\n\u003e inView('.someSelector').on('enter', doSomething);\n\u003e ```\n\n### inView(\\\u003cselector\u003e).once(\\\u003cevent\u003e, \\\u003chandler\u003e)\n\u003e Register a handler to the elements selected by `selector` for `event`. Handlers registered with `once` will only be called once.\n\n\u003e ```js\n\u003e inView('.someSelector').once('enter', doSomething);\n\u003e ```\n\n### inView.is(\\\u003celement\u003e)\n\u003e Check if `element` is in the viewport.\n\n\u003e ```js\n\u003e inView.is(document.querySelector('.someSelector'));\n\u003e // =\u003e true\n\u003e ```\n\n### inView.offset(\\\u003coffset\u003e)\n\u003e By default, in-view considers something in viewport if it breaks any edge of the viewport. This can be used to set an offset from that edge. For example, an offset of `100` will consider elements in viewport if they break any edge of the viewport by at least `100` pixels. `offset` can be a positive or negative integer.\n\n\u003e ```js\n\u003e inView.offset(100);\n\u003e inView.offset(-50);\n\u003e ```\n\n\u003e Offset can also be set per-direction by passing an object.\n\n\u003e ```js\n\u003e inView.offset({\n\u003e     top: 100,\n\u003e     right: 75,\n\u003e     bottom: 50,\n\u003e     left: 25\n\u003e });\n\u003e ```\n\n### inView.threshold(\\\u003cthreshold\u003e)\n\u003e Set the ratio of an element's height **and** width that needs to be visible for it to be considered in viewport. This defaults to `0`, meaning any amount. A threshold of `0.5` or `1` will require that half or all, respectively, of an element's height and width need to be visible. `threshold` must be a number between `0` and `1`.\n\u003e ```js\n\u003e inView.threshold(0);\n\u003e inView.threshold(0.5);\n\u003e inView.threshold(1);\n\u003e ```\n\n### inView.test(\\\u003ctest\u003e)\n\u003e Override in-view's default visibility criteria with a custom function. This function will receive the element and the options object as its only two arguments. Return `true` when an element should be considered visible and `false` otherwise.\n\u003e ```js\n\u003e inView.test((el, options) =\u003e {\n\u003e     // ...\n\u003e });\n\u003e ```\n\n### inView(\\\u003cselector\u003e).check()\n\u003e Manually check the status of the elements selected by `selector`. By default, all registries are checked on `window`'s `scroll`, `resize`, and `load` events.\n\n\u003e ```js\n\u003e inView('.someSelector').check();\n\u003e ```\n\n### inView(\\\u003cselector\u003e).emit(\\\u003cevent\u003e, \\\u003celement\u003e)\n\u003e Manually emit `event` for any single element.\n\n\u003e ```js\n\u003e inView('.someSelector').emit('exit', document.querySelectorAll('.someSelector')[0]);\n\u003e ```\n\n---\n\n## Browser Support\n\n**in-view supports all modern browsers and IE9+.**\n\nAs a small caveat, in-view utilizes [MutationObserver](https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver) to check the visibility of registered elements after a DOM mutation. If that's functionality you need in IE9-10, consider using a [polyfill](https://github.com/webcomponents/webcomponentsjs/blob/master/src/MutationObserver/MutationObserver.js).\n\n---\n\n## Performance\n\nAny library that watches scroll events runs the risk of degrading page performance. To mitigate this, currently, in-view only registers a single, throttled (maximum once every 100ms) event listener on each of `window`'s `load`, `resize`, and `scroll` events and uses those to run a check on each registry.\n\n### Utilizing IntersectionObserver\n\nThere's an emerging browser API, [`IntersectionObserver`](https://wicg.github.io/IntersectionObserver/), that aims to provide developers with a performant way to check the visibility of DOM elements. Going forward, in-view will aim to delegate to `IntersectionObserver` when it's supported, falling back to polling only when necessary.\n\n---\n\n**License** [MIT](https://opensource.org/licenses/MIT)\n","funding_links":[],"categories":["Plugins","UI","JavaScript","Utilities","Javascript","DOM"],"sub_categories":["Libraries","Sliders","React Components"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcamwiegert%2Fin-view","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcamwiegert%2Fin-view","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcamwiegert%2Fin-view/lists"}