{"id":24475187,"url":"https://github.com/wpj/lazy-child","last_synced_at":"2025-04-13T13:07:34.981Z","repository":{"id":34606881,"uuid":"180757034","full_name":"wpj/lazy-child","owner":"wpj","description":"React component that renders its child when it enters the viewport.","archived":false,"fork":false,"pushed_at":"2023-01-03T19:30:38.000Z","size":1894,"stargazers_count":5,"open_issues_count":15,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-13T13:07:28.291Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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-04-11T09:16:53.000Z","updated_at":"2022-05-27T16:27:10.000Z","dependencies_parsed_at":"2023-01-15T08:03:11.954Z","dependency_job_id":null,"html_url":"https://github.com/wpj/lazy-child","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wpj%2Flazy-child","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wpj%2Flazy-child/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wpj%2Flazy-child/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wpj%2Flazy-child/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wpj","download_url":"https://codeload.github.com/wpj/lazy-child/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248717242,"owners_count":21150389,"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","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":[],"created_at":"2025-01-21T09:13:54.354Z","updated_at":"2025-04-13T13:07:34.959Z","avatar_url":"https://github.com/wpj.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lazy-child\n\n[![CI Status](https://github.com/wpj/lazy-child/workflows/CI/badge.svg)](https://github.com/wpj/lazy-child/actions)\n\nReact component that renders its child when it enters the viewport.\n\n## Installation\n\n```\nnpm install lazy-child\n```\n\n## Usage\n\n```tsx\nimport Lazy from 'lazy-child';\n\nfunction LazyLoadedImageExample() {\n  return (\n    \u003cLazy\u003cHTMLImageElement\u003e\n      renderPlaceholder={(ref) =\u003e \u003cimg ref={ref} alt=\"Lazy loaded image\" /\u003e}\n    \u003e\n      \u003cimg src=\"example.jpg\" alt=\"Lazy loaded image\" /\u003e\n    \u003c/Lazy\u003e\n  );\n}\n```\n\n## API\n\n### `Lazy`\n\n#### Props\n\n##### `children: React.ReactNode`\n\nA React element to render when the placeholder enters the viewport.\n\n##### `offsetBottom?: number`\n\nPassed to the wrapped [react-peekaboo](https://github.com/wpj/react-peekaboo)\ninstance.\n\nNumber of pixels to add to the bottom of the area checked against when computing\nin view elements.\n\nDefault: `0`\n\n##### `offsetLeft?: number`\n\nPassed to the wrapped [react-peekaboo](https://github.com/wpj/react-peekaboo)\ninstance.\n\nNumber of pixels to add to the left of the area checked against when computing\nin view elements.\n\nDefault: `0`\n\n##### `offsetRight?: number`\n\nPassed to the wrapped [react-peekaboo](https://github.com/wpj/react-peekaboo)\ninstance.\n\nNumber of pixels to add to the right of the area checked against when computing\nin view elements.\n\nDefault: `0`\n\n##### `offsetTop?: number`\n\nPassed to the wrapped [react-peekaboo](https://github.com/wpj/react-peekaboo)\ninstance.\n\nNumber of pixels to add to the top of the area checked against when computing in\nview elements.\n\nDefault: `0`\n\n##### `renderPlaceholder\u003cE extends HTMLElement\u003e: (ref: React.Ref\u003cE\u003e) =\u003e React.ReactNode`\n\nRender prop that returns a React element to use as a placeholder. The function\nreceives a ref as its first parameter that must be applied to a DOM element.\n\n##### `throttle?: number`\n\nPassed to the wrapped [react-peekaboo](https://github.com/wpj/react-peekaboo)\ninstance.\n\nNumber of ms to throttle scroll events (only applies in environments that don't\nsupport IntersectionObserver).\n\nDefault: `100`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwpj%2Flazy-child","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwpj%2Flazy-child","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwpj%2Flazy-child/lists"}