{"id":13810469,"url":"https://github.com/metonym/svelte-intersection-observer","last_synced_at":"2026-01-19T21:00:43.218Z","repository":{"id":40794846,"uuid":"253362397","full_name":"metonym/svelte-intersection-observer","owner":"metonym","description":"Detect if an element is in the viewport using the Intersection Observer API","archived":false,"fork":false,"pushed_at":"2026-01-18T00:22:32.000Z","size":1117,"stargazers_count":338,"open_issues_count":14,"forks_count":9,"subscribers_count":3,"default_branch":"master","last_synced_at":"2026-01-18T12:22:40.226Z","etag":null,"topics":["conditional","intersection-event","intersection-observer","lazy-loading","svelte","svelte-component","typescript-definitions","viewport"],"latest_commit_sha":null,"homepage":"https://metonym.github.io/svelte-intersection-observer/","language":"Svelte","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/metonym.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2020-04-06T00:46:00.000Z","updated_at":"2025-11-23T09:06:54.000Z","dependencies_parsed_at":"2024-05-19T06:26:01.474Z","dependency_job_id":"7ec7ea13-1afa-435e-961d-79d4a6a8a5af","html_url":"https://github.com/metonym/svelte-intersection-observer","commit_stats":{"total_commits":171,"total_committers":6,"mean_commits":28.5,"dds":"0.14035087719298245","last_synced_commit":"65dfc7a4b48e20dac88a97cd21e6f5874afac8d2"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/metonym/svelte-intersection-observer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metonym%2Fsvelte-intersection-observer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metonym%2Fsvelte-intersection-observer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metonym%2Fsvelte-intersection-observer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metonym%2Fsvelte-intersection-observer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/metonym","download_url":"https://codeload.github.com/metonym/svelte-intersection-observer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metonym%2Fsvelte-intersection-observer/sbom","scorecard":{"id":638264,"data":{"date":"2025-08-11","repo":{"name":"github.com/metonym/svelte-intersection-observer","commit":"85f0fd78effb265997364ddafb6175ae4a2ecabe"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.5,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/22 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":1,"reason":"2 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 1","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"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":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","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":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Info: jobLevel 'contents' permission set to 'read': .github/workflows/release.yml:10","Warn: no topLevel permission defined: .github/workflows/ci.yml:1","Warn: no topLevel permission defined: .github/workflows/release.yml:1","Info: no jobLevel write permissions found"],"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":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:10: update your workflow using https://app.stepsecurity.io/secureworkflow/metonym/svelte-intersection-observer/ci.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/metonym/svelte-intersection-observer/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/metonym/svelte-intersection-observer/ci.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:37: update your workflow using https://app.stepsecurity.io/secureworkflow/metonym/svelte-intersection-observer/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/metonym/svelte-intersection-observer/release.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/metonym/svelte-intersection-observer/release.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/metonym/svelte-intersection-observer/release.yml/master?enable=pin","Info:   0 out of   4 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   3 third-party GitHubAction dependencies pinned"],"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":"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":"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":"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":"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":"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":"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":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 14 are checked with a SAST tool"],"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-21T09:55:06.202Z","repository_id":40794846,"created_at":"2025-08-21T09:55:06.202Z","updated_at":"2025-08-21T09:55:06.202Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28585183,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-19T20:45:59.482Z","status":"ssl_error","status_checked_at":"2026-01-19T20:45:41.500Z","response_time":67,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["conditional","intersection-event","intersection-observer","lazy-loading","svelte","svelte-component","typescript-definitions","viewport"],"created_at":"2024-08-04T02:00:54.721Z","updated_at":"2026-01-19T21:00:43.204Z","avatar_url":"https://github.com/metonym.png","language":"Svelte","funding_links":[],"categories":["Svelte"],"sub_categories":[],"readme":"# svelte-intersection-observer\n\n[![NPM][npm]][npm-url]\n\n\u003e Detect if an element is in the viewport using the [Intersection Observer API](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API).\n\n\u003c!-- REPO_URL --\u003e\n\nTry it in the [Svelte REPL](https://svelte.dev/repl/8cd2327a580c4f429c71f7df999bd51d).\n\n\u003c!-- TOC --\u003e\n\n## Installation\n\n```sh\n# NPM\nnpm i svelte-intersection-observer\n\n# pnpm\npnpm i svelte-intersection-observer\n\n# Bun\nbun i svelte-intersection-observer\n\n# Yarn\nyarn add svelte-intersection-observer\n\n```\n\n## Usage\n\n### Basic\n\nUse the [`bind:this`](https://svelte.dev/docs#bind_element) directive to pass an element reference to the `IntersectionObserver` component.\n\nThen, simply bind to the reactive `intersecting` prop to determine if the element intersects the viewport.\n\n```svelte\n\u003cscript\u003e\n  import IntersectionObserver from \"svelte-intersection-observer\";\n\n  let element;\n  let intersecting;\n\u003c/script\u003e\n\n\u003cheader class:intersecting\u003e\n  {intersecting ? \"Element is in view\" : \"Element is not in view\"}\n\u003c/header\u003e\n\n\u003cIntersectionObserver {element} bind:intersecting\u003e\n  \u003cdiv bind:this={element}\u003eHello world\u003c/div\u003e\n\u003c/IntersectionObserver\u003e\n```\n\n### Once\n\nSet `once` to `true` for the intersection event to occur only once. The `element` will be unobserved after the first intersection event occurs.\n\n```svelte\n\u003cscript\u003e\n  import IntersectionObserver from \"svelte-intersection-observer\";\n\n  let elementOnce;\n  let intersectOnce;\n\u003c/script\u003e\n\n\u003cheader class:intersecting={intersectOnce}\u003e\n  {intersectOnce ? \"Element is in view\" : \"Element is not in view\"}\n\u003c/header\u003e\n\n\u003cIntersectionObserver\n  once\n  element={elementOnce}\n  bind:intersecting={intersectOnce}\n\u003e\n  \u003cdiv bind:this={elementOnce}\u003eHello world\u003c/div\u003e\n\u003c/IntersectionObserver\u003e\n```\n\n### `let:intersecting`\n\nAn alternative to binding to the `intersecting` prop is to use the `let:` directive.\n\nIn the following example, the \"Hello world\" element will fade in when its containing element intersects the viewport.\n\n```svelte\n\u003cscript\u003e\n  import IntersectionObserver from \"svelte-intersection-observer\";\n  import { fade } from \"svelte/transition\";\n\n  let node;\n\u003c/script\u003e\n\n\u003cheader /\u003e\n\n\u003cIntersectionObserver element={node} let:intersecting\u003e\n  \u003cdiv bind:this={node}\u003e\n    {#if intersecting}\n      \u003cdiv transition:fade={{ delay: 200 }}\u003eHello world\u003c/div\u003e\n    {/if}\n  \u003c/div\u003e\n\u003c/IntersectionObserver\u003e\n```\n\n### `on:observe` event\n\nThe `observe` event is dispatched when the element is first observed and also whenever an intersection event occurs.\n\n```svelte no-eval\n\u003cIntersectionObserver\n  {element}\n  on:observe={(e) =\u003e {\n    console.log(e.detail); // IntersectionObserverEntry\n    console.log(e.detail.isIntersecting); // true | false\n  }}\n\u003e\n  \u003cdiv bind:this={element}\u003eHello world\u003c/div\u003e\n\u003c/IntersectionObserver\u003e\n```\n\n### `on:intersect` event\n\nAs an alternative to binding the `intersecting` prop, you can listen to the `intersect` event that is dispatched if the observed element is intersecting the viewport.\n\n**Note**: Compared to `on:observe`, `on:intersect` is dispatched only when the element is _intersecting the viewport_. In other words, `e.detail.isIntersecting` will only be `true`.\n\n```svelte no-eval\n\u003cIntersectionObserver\n  {element}\n  on:intersect={(e) =\u003e {\n    console.log(e.detail); // IntersectionObserverEntry\n    console.log(e.detail.isIntersecting); // true\n  }}\n\u003e\n  \u003cdiv bind:this={element}\u003eHello world\u003c/div\u003e\n\u003c/IntersectionObserver\u003e\n```\n\n### Multiple elements\n\nFor performance, use `MultipleIntersectionObserver` to observe multiple elements.\n\nThis avoids instantiating a new observer for every element.\n\n```svelte\n\u003cscript\u003e\n  import { MultipleIntersectionObserver } from \"svelte-intersection-observer\";\n\n  let ref1;\n  let ref2;\n\n  $: elements = [ref1, ref2];\n\u003c/script\u003e\n\n\u003cMultipleIntersectionObserver {elements} let:elementIntersections\u003e\n  \u003cheader\u003e\n    \u003cdiv class:intersecting={elementIntersections.get(ref1)}\u003e\n      Item 1: {elementIntersections.get(ref1) ? \"✓\" : \"✗\"}\n    \u003c/div\u003e\n    \u003cdiv class:intersecting={elementIntersections.get(ref2)}\u003e\n      Item 2: {elementIntersections.get(ref2) ? \"✓\" : \"✗\"}\n    \u003c/div\u003e\n  \u003c/header\u003e\n\n  \u003cdiv bind:this={ref1}\u003eItem 1\u003c/div\u003e\n  \u003cdiv bind:this={ref2}\u003eItem 2\u003c/div\u003e\n\u003c/MultipleIntersectionObserver\u003e\n```\n\n## API\n\n### IntersectionObserver\n\n#### Props\n\n| Name         | Description                                                 | Type                                                                                                                | Default value |\n| :----------- | :---------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------ | :------------ |\n| element      | Observed element                                            | `null` or `HTMLElement`                                                                                             | `null`        |\n| once         | Unobserve the element after the first intersection event    | `boolean`                                                                                                           | `false`       |\n| intersecting | `true` if the observed element is intersecting the viewport | `boolean`                                                                                                           | `false`       |\n| root         | Containing element                                          | `null` or `HTMLElement`                                                                                             | `null`        |\n| rootMargin   | Margin offset of the containing element                     | `string`                                                                                                            | `\"0px\"`       |\n| threshold    | Percentage of element visibility to trigger an event        | `number` between 0 and 1, or an array of `number`s between 0 and 1                                                  | `0`           |\n| entry        | Observed element metadata                                   | `null` or [`IntersectionObserverEntry`](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserverEntry) | `null`        |\n| observer     | `IntersectionObserver` instance                             | `null` or [`IntersectionObserver`](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver)           | `null`        |\n\n#### Dispatched events\n\n- **on:observe**: fired when the element is first observed or whenever an intersection change occurs\n- **on:intersect**: fired when the element is intersecting the viewport\n\nThe `e.detail` dispatched by the `observe` and `intersect` events is an [`IntersectionObserverEntry`](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserverEntry) interface.\n\n#### Slot props\n\n| Name         | Type                                                                                                                |\n| :----------- | :------------------------------------------------------------------------------------------------------------------ |\n| intersecting | `boolean`                                                                                                           |\n| entry        | `null` or [`IntersectionObserverEntry`](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserverEntry) |\n| observer     | [`IntersectionObserver`](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver)                     |\n\n### MultipleIntersectionObserver\n\n#### Props\n\n| Name                 | Description                                           | Type                                                                                                                                    | Default value |\n| :------------------- | :---------------------------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------- | :------------ |\n| elements             | Array of HTML elements to observe                     | `Array\u003cHTMLElement \\| null\u003e`                                                                                                            | `[]`          |\n| once                 | Unobserve elements after the first intersection event | `boolean`                                                                                                                               | `false`       |\n| root                 | Containing element                                    | `null` or `HTMLElement`                                                                                                                 | `null`        |\n| rootMargin           | Margin offset of the containing element               | `string`                                                                                                                                | `\"0px\"`       |\n| threshold            | Percentage of element visibility to trigger an event  | `number` between 0 and 1, or an array of `number`s between 0 and 1                                                                      | `0`           |\n| elementIntersections | Map of each element to its intersection state         | `Map\u003cHTMLElement \\| null, boolean\u003e`                                                                                                     | `new Map()`   |\n| elementEntries       | Map of each element to its latest entry               | `Map\u003cHTMLElement \\| null,` [`IntersectionObserverEntry`](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserverEntry)`\u003e` | `new Map()`   |\n| observer             | `IntersectionObserver` instance                       | `null` or [`IntersectionObserver`](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver)                               | `null`        |\n\n#### Dispatched events\n\n- **on:observe**: fired when an element is first observed or whenever an intersection change occurs\n- **on:intersect**: fired when an element is intersecting the viewport\n\nThe `e.detail` for both events includes:\n\n```ts\n{\n  entry: IntersectionObserverEntry;\n  target: HTMLElement;\n}\n```\n\n#### Slot props\n\n| Name                 | Type                                                                                                                                    |\n| :------------------- | :-------------------------------------------------------------------------------------------------------------------------------------- |\n| observer             | [`IntersectionObserver`](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver)                                         |\n| elementIntersections | `Map\u003cHTMLElement \\| null, boolean\u003e`                                                                                                     |\n| elementEntries       | `Map\u003cHTMLElement \\| null,` [`IntersectionObserverEntry`](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserverEntry)`\u003e` |\n\n### `IntersectionObserverEntry` interface\n\nNote that all properties in [IntersectionObserverEntry](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserverEntry) are read-only.\n\n\u003cdetails\u003e\n \u003csummary\u003e\u003ccode\u003eIntersectionObserverEntry\u003c/code\u003e\u003c/summary\u003e\n\n```ts\ninterface IntersectionObserverEntry {\n  target: HTMLElement;\n  time: number;\n  isIntersecting: boolean;\n  isVisible: boolean;\n  intersectionRatio: number;\n  intersectionRect: {\n    bottom: number;\n    height: number;\n    left: number;\n    right: number;\n    top: number;\n    width: number;\n    x: number;\n    y: number;\n  };\n  rootBounds: {\n    bottom: number;\n    height: number;\n    left: number;\n    right: number;\n    top: number;\n    width: number;\n    x: number;\n    y: number;\n  };\n  boundingClientRect: {\n    bottom: number;\n    height: number;\n    left: number;\n    right: number;\n    top: number;\n    width: number;\n    x: number;\n    y: number;\n  };\n}\n```\n\n\u003c/details\u003e\n\n## Changelog\n\n[Changelog](CHANGELOG.md)\n\n## License\n\n[MIT](LICENSE)\n\n[npm]: https://img.shields.io/npm/v/svelte-intersection-observer.svg?color=%23ff3e00\u0026style=for-the-badge\n[npm-url]: https://npmjs.com/package/svelte-intersection-observer\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetonym%2Fsvelte-intersection-observer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmetonym%2Fsvelte-intersection-observer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetonym%2Fsvelte-intersection-observer/lists"}