{"id":16326675,"url":"https://github.com/chrisyip/is-element-in-view","last_synced_at":"2025-05-14T22:12:18.012Z","repository":{"id":57277128,"uuid":"77077312","full_name":"chrisyip/is-element-in-view","owner":"chrisyip","description":"Detect if element is in view","archived":false,"fork":false,"pushed_at":"2016-12-30T05:53:59.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-10T07:03:15.925Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/chrisyip.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":"2016-12-21T18:41:30.000Z","updated_at":"2016-12-29T15:55:51.000Z","dependencies_parsed_at":"2022-09-13T05:32:03.550Z","dependency_job_id":null,"html_url":"https://github.com/chrisyip/is-element-in-view","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisyip%2Fis-element-in-view","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisyip%2Fis-element-in-view/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisyip%2Fis-element-in-view/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisyip%2Fis-element-in-view/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chrisyip","download_url":"https://codeload.github.com/chrisyip/is-element-in-view/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254235712,"owners_count":22036966,"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":"2024-10-10T23:09:15.541Z","updated_at":"2025-05-14T22:12:17.984Z","avatar_url":"https://github.com/chrisyip.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# is-element-in-view\nDetect if element is in view.\n\n```\nnpm install is-element-in-view\n```\n\nUse with module packer with `babel-preset-es2015`, e.g. `webpack`:\n\n```\nimport isElementInView from 'is-element-in-view\n```\n\nWith CommonJS:\n\n```\nconst isElementInView = require('is-element-in-view/dist/is-element-in-view')\n```\n\nWith `\u003cscript\u003e` tag:\n\n```\n\u003cscript src=\"node_modules/is-element-in-view/dist/is-element-in-view.umd.js\"\n```\n\n## Usage\n\n```\nconst elementInView = isElementInView(element)\n/*\n * returns\n * {\n *   top: true,\n *   bottom: true,\n *   left: true,\n *   right: true,\n *   body: true,\n * }\n */\n```\n\n```\nif (!isElementInView(element).top) {\n  element.scrollIntoView()\n}\n```\n\n### Options\n\n`element`: target element.\n\n`parentElement`: optional, accepts a HTML element, if presented, will use `parentElement.getBoundingClientRect()` as viewport, otherwise, use `window.innerHeight` and `window.innerWidth` instead.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrisyip%2Fis-element-in-view","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchrisyip%2Fis-element-in-view","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrisyip%2Fis-element-in-view/lists"}