{"id":40346640,"url":"https://github.com/darlesson/viewport-action","last_synced_at":"2026-01-20T09:30:24.877Z","repository":{"id":33783799,"uuid":"161742046","full_name":"darlesson/viewport-action","owner":"darlesson","description":"Check when an element is on the viewport.","archived":false,"fork":false,"pushed_at":"2025-07-17T21:32:27.000Z","size":823,"stargazers_count":3,"open_issues_count":3,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-20T05:54:38.098Z","etag":null,"topics":["cordova","devices","dimensions","document","events","intersection","lazy-load","mobile","observer","performance","phonegap","resize","responsive","scroll","size","state","viewport","visible","web","window"],"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/darlesson.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,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2018-12-14T06:33:16.000Z","updated_at":"2024-12-05T05:20:14.000Z","dependencies_parsed_at":"2024-02-13T02:30:40.695Z","dependency_job_id":"f1160542-20cd-4d59-ab5f-f329e89ab1b1","html_url":"https://github.com/darlesson/viewport-action","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/darlesson/viewport-action","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darlesson%2Fviewport-action","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darlesson%2Fviewport-action/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darlesson%2Fviewport-action/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darlesson%2Fviewport-action/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/darlesson","download_url":"https://codeload.github.com/darlesson/viewport-action/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darlesson%2Fviewport-action/sbom","scorecard":{"id":322997,"data":{"date":"2025-08-11","repo":{"name":"github.com/darlesson/viewport-action","commit":"e834f4d07c20066ba630d22f112bdacb0e8a5711"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Code-Review","score":0,"reason":"Found 0/2 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 29 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"11 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-c7qv-q95q-8v27","Warn: Project is vulnerable to: GHSA-4www-5p9h-95mh","Warn: Project is vulnerable to: GHSA-9gqv-wp59-fq42","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-76c9-3jph-rj3q","Warn: Project is vulnerable to: GHSA-rhx6-c78j-4q9w","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-4v9v-hfq4-rm2v","Warn: Project is vulnerable to: GHSA-9jgg-88mc-972h"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-18T01:49:42.214Z","repository_id":33783799,"created_at":"2025-08-18T01:49:42.214Z","updated_at":"2025-08-18T01:49:42.214Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28600419,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-20T08:51:33.170Z","status":"ssl_error","status_checked_at":"2026-01-20T08:51:10.855Z","response_time":117,"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":["cordova","devices","dimensions","document","events","intersection","lazy-load","mobile","observer","performance","phonegap","resize","responsive","scroll","size","state","viewport","visible","web","window"],"created_at":"2026-01-20T09:30:23.029Z","updated_at":"2026-01-20T09:30:24.868Z","avatar_url":"https://github.com/darlesson.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Viewport Action\n\nProvides a way with extra configuration options to execute a handler when a given element is on view.\n\nFew things to know:\n\n* It checks when an element is on view as soon as it's added to `viewportAction`.\n* It skips all elements that are not on view at the moment the event triggers the handler.\nThis means it will not call the handlers for elements that where just scrolled over.\n\n## Example\n\nhttps://codepen.io/rooyva/pen/aPWNXQ\n\n## Installation\n\n### Using NPM\n\n```shell\nnpm i viewport-action\n```\n\n### Using CDN\n\n```html\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/viewport-action@1.0.1/dist/viewportAction.min.js\"\u003e\u003c/script\u003e\n```\n\n### Download files\n\nYou can download the distribution files from https://github.com/darlesson/viewport-action/tree/master/dist\n\n## Usage\n\n```javascript\n// Importing with ES6\nimport viewportAction from 'viewport-action';\n```\n\n```javascript\n// Using RequireJS\nrequire(['./src/viewportAction.min'], (viewportAction) =\u003e {\n\n});\n```\n\n```javascript\n// Global reference when not using Require JS\nwindow.viewportAction;\n```\n\n#### Bind a handler to an element\n\nYou can add elements or selectors with the handlers. The `add` method waits for `whenDocumentReady`\nto execute a callback when the document is ready. Only one element can be bound per handler.\n\n```javascript\nviewportAction.add('#selector', (e) =\u003e { /* Code here */ });\n\n// or\n\nviewportAction.add(document.getElementById('selector'), (e) =\u003e { /* Code here */ });\n```\n\n#### The event object\n\nThe event object is an instance of the custom `ViewportEvent` class. It returns details that can be used to\ndetermine the conditions to change the element bound to the handler.\n\n```javascript\n{\n    // The event name.\n    type: 'viewport',\n    // Resize or scroll event instances.\n    originalEvent: event,\n    // The element bound with the handler.\n    target: element,\n    // The same as target.\n    currentTarget: element,\n    // The same as target.\n    srcElement: element,\n    // The timeStamp from `originalEvent.timeStamp`.\n    timeStamp: 345,\n    // The event detail object.\n    detail: {\n        // The element's area visible on the viewport\n        availableArea: 318425.015625,\n        // The space between the bottom of the viewport and the bottom\n        // of the element while in the viewport.\n        availableTop: 0,\n        // The space between the top of the viewport and the top of the\n        // element while in the viewport.\n        availableBottom: 440.421875,\n        // The element's height shown in the viewport.\n        availableHeight: 440.421875,\n        // The space between the left of the viewport and the left of the\n        // element while in the viewport.\n        availableLeft: 118,\n        // The space between the right of the viewport and the right of the\n        // element while in the viewport.\n        availableRight: 841,\n        // The element's width shown in the viewport.\n        availableWidth: 723,\n        // The same as `element.getBoundingClientRect().top`.\n        top: -63.578125,\n        // The same as `element.getBoundingClientRect().bottom`.\n        bottom: 440.421875,\n        // The same as `element.getBoundingClientRect().height`.\n        height: 504,\n        // The same as `element.getBoundingClientRect().left`.\n        left: 118,\n        // The same as `element.getBoundingClientRect().right`.\n        right: 841,\n        // The same as `element.getBoundingClientRect().width`.\n        width: 723\n    }\n}\n```\n\n#### Setting options\n\nBelow are some options that can be passed when adding the element and handler and their default values.\n\n```javascript\nconst options = {\n    // How long the handler will wait after the original event stops triggering.\n    wait: 50,\n    // Whether to unbind the handler after executed for the first time.\n    once: false\n};\n\nviewportAction.add('#selector', (e) =\u003e { /* Code here */ }, options);\n```\n\n#### Executing the handler once\n\nYou can have the handler unbinding on the first time the element is on the viewport.\n\n```javascript\nconst options = {\n    once: true\n};\n\nviewportAction.add('#selector', (e) =\u003e {\n    e.target.innerText = 'Element on viewport.';\n}, options);\n```\n\n#### Unbing the handler when meeting a condition\n\nYou can allow the handler to be executed until a condition is met and only then unbind it.\n\n```javascript\nviewportAction.add('#selector', (e) =\u003e {\n\n    // Load an image inside the element when the area visible is bigger\n    // than 1000 pixels.\n    if (e.detail.availableArea \u003e 1000) {\n\n        e.target.innerText = 'Element on viewport.';\n\n        // Remove handler\n        e.removeHandler();\n    }\n});\n```\n\n#### Check whether an element is on the viewport\n\nYou can check whether an element is on the viewport on demand without waiting for document changes.\n\n```javascript\n// You can use a selector or the element itself\nviewportAction.check('#selector', (e) =\u003e {\n    // Code here\n}, () =\u003e {\n    // Optional callback handler if the element is not on the document. Just one of the\n    // 2 callbacks is called.\n});\n```\n\n## Testing and developing\n\nYou can run the command below to build the application and run a server to test and deveop.\n\n```\nnpm start\n```\n\nOpen http://localhost:9000/ on your browser.\n\n## License\n\n[MIT License](https://github.com/darlesson/viewport-action/blob/master/LICENSE)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdarlesson%2Fviewport-action","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdarlesson%2Fviewport-action","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdarlesson%2Fviewport-action/lists"}