{"id":24475171,"url":"https://github.com/wpj/react-peekaboo","last_synced_at":"2026-04-14T23:32:26.396Z","repository":{"id":34308476,"uuid":"176585739","full_name":"wpj/react-peekaboo","owner":"wpj","description":"React hooks for monitoring an element's intersection with the viewport","archived":false,"fork":false,"pushed_at":"2023-01-06T14:24:29.000Z","size":2332,"stargazers_count":1,"open_issues_count":15,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-10-13T10:03:03.279Z","etag":null,"topics":["intersectionobserver","react"],"latest_commit_sha":null,"homepage":"","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/wpj.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":"2019-03-19T19:36:57.000Z","updated_at":"2021-02-05T04:04:32.000Z","dependencies_parsed_at":"2023-01-15T06:13:59.576Z","dependency_job_id":null,"html_url":"https://github.com/wpj/react-peekaboo","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/wpj/react-peekaboo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wpj%2Freact-peekaboo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wpj%2Freact-peekaboo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wpj%2Freact-peekaboo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wpj%2Freact-peekaboo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wpj","download_url":"https://codeload.github.com/wpj/react-peekaboo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wpj%2Freact-peekaboo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31819718,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-14T18:05:02.291Z","status":"ssl_error","status_checked_at":"2026-04-14T18:05:01.765Z","response_time":153,"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":["intersectionobserver","react"],"created_at":"2025-01-21T09:13:50.524Z","updated_at":"2026-04-14T23:32:26.371Z","avatar_url":"https://github.com/wpj.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `react-peekaboo`\n\n[![CI Status](https://github.com/wpj/react-peekaboo/workflows/CI/badge.svg)](https://github.com/wpj/react-peekaboo/actions)\n\nReact hooks for monitoring an element's intersection with the viewport.\n\n## Installation\n\n```\nnpm install react-peekaboo\n```\n\n## Usage\n\n```tsx\nimport React, { useState } from 'react';\nimport { useIntersecting, useIntersectionChange } from 'react-peekaboo';\n\nfunction UseIntersectionExample() {\n  let [ref, isIntersecting] = useIntersecting\u003cHTMLDivElement\u003e();\n\n  return (\n    \u003cdiv ref={ref}\u003eI am {isIntersecting ? 'visible' : 'not visible'}.\u003c/div\u003e\n  );\n}\n\nfunction UseIntersectionChangeExample() {\n  let [isIntersecting, onChange] = useState\u003cboolean\u003e(false);\n  let ref = useIntersectionChange\u003cHTMLDivElement\u003e(onChange);\n\n  return (\n    \u003cdiv ref={ref}\u003eI am {isIntersecting ? 'visible' : 'not visible'}.\u003c/div\u003e\n  );\n}\n```\n\n## API\n\n### Options\n\nAll functions accept a common set of options:\n\n- `enabled?: boolean`: Enables/disables running the side effect that calculates\n  the element's intersection status. (default: `true`)\n\n- `offsetBottom?: number`: Number of pixels to add to the bottom of the area\n  checked against when computing element intersection. (default: `0`)\n\n- `offsetLeft?: number`: Number of pixels to add to the left of the area checked\n  against when computing element intersection. (default: `0`)\n\n- `offsetRight?: number`: Number of pixels to add to the right of the area\n  checked against when computing element intersection. (default: `0`)\n\n- `offsetTop?: number`: Number of pixels to add to the top of the area checked\n  against when computing element intersection. (default: `0`)\n\n- `throttle?: number`: Number of ms to throttle scroll events (only applies in\n  environments that don't support IntersectionObserver or when using\n  `useScrollIntersection`/`useScrollIntersectionChangeCallback`). (default:\n  `100`)\n\n### Exports\n\n#### `useIntersecting`\n\nType: `(options: Options) =\u003e [RefCallback, boolean]`\n\nReturns a ref and the element's intersection status using IntersectionObserver\nor `scroll`/`resize` event listeners and `getBoundingClientRect` in unsupported\nenvironments.\n\nThe ref returned must be attached to a DOM node.\n\n#### `useIntersectionChange`\n\nType:\n\n```typescript\n(onChange: (isIntersecting: boolean) =\u003e void, options: Options) =\u003e RefCallback;\n```\n\nRuns a callback that receives the element's intersection status each time it\nchanges using IntersectionObserver or `scroll`/`resize` event listeners and\n`getBoundingClientRect` in unsupported environments.\n\nReturns a ref that must be attached to a DOM node.\n\n#### `usePeekaboo`\n\nType:\n\n```typescript\ntype SetupHandler = (\n  element: HTMLElement,\n  onChange: (isIntersecting: boolean) =\u003e void,\n  options?: Options,\n) =\u003e TeardownHandler;\n\n(\n  setup: SetupHandler,\n  onChange: (isIntersecting: boolean) =\u003e void,\n  options?: Options,\n) =\u003e RefCallback;\n```\n\nUses `setup` to run `onChange` when the element's intersection status changes.\nYou can pass `scroll`, `io`, or `peekaboo` from `dom-peekaboo` or implement your\nown setup function.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwpj%2Freact-peekaboo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwpj%2Freact-peekaboo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwpj%2Freact-peekaboo/lists"}