{"id":15914681,"url":"https://github.com/andy2046/skywatch","last_synced_at":"2025-04-03T03:44:30.738Z","repository":{"id":57362630,"uuid":"111215637","full_name":"andy2046/skywatch","owner":"andy2046","description":"JavaScript library to observe selected elements enter or leave the viewport","archived":false,"fork":false,"pushed_at":"2018-03-14T05:03:53.000Z","size":192,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-09-20T05:27:56.660Z","etag":null,"topics":["callback","htmlelement","javascript","mutationobserver","reactive","resize","viewport"],"latest_commit_sha":null,"homepage":"","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/andy2046.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":"2017-11-18T15:18:27.000Z","updated_at":"2019-06-09T02:38:41.000Z","dependencies_parsed_at":"2022-09-26T16:32:15.287Z","dependency_job_id":null,"html_url":"https://github.com/andy2046/skywatch","commit_stats":null,"previous_names":[],"tags_count":5,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andy2046%2Fskywatch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andy2046%2Fskywatch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andy2046%2Fskywatch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andy2046%2Fskywatch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andy2046","download_url":"https://codeload.github.com/andy2046/skywatch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246933357,"owners_count":20857052,"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":["callback","htmlelement","javascript","mutationobserver","reactive","resize","viewport"],"created_at":"2024-10-06T17:05:17.185Z","updated_at":"2025-04-03T03:44:30.719Z","avatar_url":"https://github.com/andy2046.png","language":"JavaScript","readme":"# skywatch\nskywatch is a JavaScript library to observe selected elements enter or leave the viewport or resize.\n\n## Examples\n```js\nimport { ViewportObserver, ResizeObserver } from 'skywatch'\n\nconst callback = (element, event) =\u003e {\n  console.log(element, event)\n}\n\n// ViewportObserver\nconst obs = ViewportObserver.of({ debounce: 1000, tolerance: 20, container: window })\n\n// callback when element enter the viewport\nobs.subscribe('enter', 'div.element', callback)\n\n// callback when element leave the viewport\nobs.subscribe('leave', 'div.element', callback)\n\n// check if element is in Viewport\nViewportObserver.inViewport('div.element')\n\n// cleanup\nobs.unsubscribe('enter', 'div.element', callback)\nobs.unsubscribe('leave', 'div.element', callback)\nobs.disconnect()\n\n// ResizeObserver\nconst reobs = ResizeObserver.of(callback)\n\n// observe target element\nreobs.observe('div.element')\n\n// unobserve target element\nreobs.unobserve('div.element')\n\n// cleanup\nreobs.disconnect()\n```\n\n## Installation\n\n```\nnpm install --save skywatch\n```\n\n## Usage\nYou can import from `skywatch`:\n\n```js\nimport { ViewportObserver, ResizeObserver } from 'skywatch'\n// or\nconst { ViewportObserver, ResizeObserver } = require('skywatch')\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandy2046%2Fskywatch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandy2046%2Fskywatch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandy2046%2Fskywatch/lists"}