{"id":24030507,"url":"https://github.com/callmecavs/obzerv","last_synced_at":"2025-04-19T11:51:22.910Z","repository":{"id":57313204,"uuid":"106314379","full_name":"callmecavs/obzerv","owner":"callmecavs","description":"A convenient wrapper around IntersectionObserver for tracking element position relative to the viewport.","archived":false,"fork":false,"pushed_at":"2017-10-10T23:23:26.000Z","size":35,"stargazers_count":11,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-09T18:09:13.777Z","etag":null,"topics":["intersectionobserver"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/callmecavs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-09T17:33:20.000Z","updated_at":"2025-03-10T22:49:18.000Z","dependencies_parsed_at":"2022-09-20T23:10:43.351Z","dependency_job_id":null,"html_url":"https://github.com/callmecavs/obzerv","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/callmecavs%2Fobzerv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/callmecavs%2Fobzerv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/callmecavs%2Fobzerv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/callmecavs%2Fobzerv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/callmecavs","download_url":"https://codeload.github.com/callmecavs/obzerv/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249687530,"owners_count":21311066,"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":["intersectionobserver"],"created_at":"2025-01-08T17:44:36.330Z","updated_at":"2025-04-19T11:51:22.880Z","avatar_url":"https://github.com/callmecavs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# obzerv\n\n[![obzerv on NPM](https://img.shields.io/npm/v/obzerv.svg?style=flat-square)](https://www.npmjs.com/package/obzerv) [![obzerv Downloads on NPM](https://img.shields.io/npm/dm/obzerv.svg?style=flat-square)](https://www.npmjs.com/package/obzerv) [![Standard JavaScript Style](https://img.shields.io/badge/code_style-standard-brightgreen.svg?style=flat-square)](http://standardjs.com/)\n\nA convenient wrapper around [`IntersectionObserver`](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API) for tracking element position relative to the viewport.\n\n## Install\n\n```sh\n$ npm i obzerv --save\n```\n\n## API\n\n### .create(options)\n\nAccepts a config object with `callback` and `offset` properties. Returns an observer instance with a `track` function used to add nodes to the observer.\n\n```javascript\nimport obzerv from 'obzerv'\n\n// example callback: lazy loading an image\nconst callback = (node, inview, untrack) =\u003e {\n  // exit early if image not in viewport\n  if (!inview) {\n    return\n  }\n\n  // set src attribute of the image\n  node.setAttribute('src', node.getAttribute('data-src'))\n\n  // stop tracking image, because load attempt has been initiated\n  untrack()\n}\n\n// create an observer instance\nconst observer = obzerv.create({\n  callback,\n  offset: 25\n})\n\n// add all .box elements to the observer\nArray\n  .from(document.querySelectorAll('.box'))\n  .forEach(box =\u003e observer.track(box))\n```\n\n## License\n\n[MIT](https://opensource.org/licenses/MIT). © 2017 Michael Cavalea\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcallmecavs%2Fobzerv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcallmecavs%2Fobzerv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcallmecavs%2Fobzerv/lists"}