{"id":13447871,"url":"https://github.com/vissense/vissense","last_synced_at":"2025-10-05T22:40:43.799Z","repository":{"id":20563396,"uuid":"23843531","full_name":"vissense/vissense","owner":"vissense","description":"A utility library for observing visibility changes of DOM elements.","archived":false,"fork":false,"pushed_at":"2020-01-19T20:26:47.000Z","size":1521,"stargazers_count":824,"open_issues_count":1,"forks_count":31,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-09-23T12:31:44.286Z","etag":null,"topics":["visibility"],"latest_commit_sha":null,"homepage":"https://vissense.github.io/vissense","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/vissense.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-09-09T17:26:46.000Z","updated_at":"2025-08-18T14:46:53.000Z","dependencies_parsed_at":"2022-08-21T18:40:57.808Z","dependency_job_id":null,"html_url":"https://github.com/vissense/vissense","commit_stats":null,"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"purl":"pkg:github/vissense/vissense","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vissense%2Fvissense","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vissense%2Fvissense/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vissense%2Fvissense/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vissense%2Fvissense/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vissense","download_url":"https://codeload.github.com/vissense/vissense/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vissense%2Fvissense/sbom","scorecard":{"id":923740,"data":{"date":"2025-08-04","repo":{"name":"github.com/vissense/vissense","commit":"b3d6be4aaed863ace94ddc01be3299f65daeaf99"},"scorecard":{"version":"v5.2.1-28-gc1d103a9","commit":"c1d103a9bb9f635ec7260bf9aa0699466fa4be0e"},"score":3.5,"checks":[{"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/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#maintained"}},{"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/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#token-permissions"}},{"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/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#dangerous-workflow"}},{"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/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/29 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/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#code-review"}},{"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/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#binary-artifacts"}},{"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/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#pinned-dependencies"}},{"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/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/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/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#vulnerabilities"}},{"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/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/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/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/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/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/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/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/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 2 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/c1d103a9bb9f635ec7260bf9aa0699466fa4be0e/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-25T08:21:55.286Z","repository_id":20563396,"created_at":"2025-08-25T08:21:55.286Z","updated_at":"2025-08-25T08:21:55.286Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278532360,"owners_count":26002345,"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","status":"online","status_checked_at":"2025-10-05T02:00:06.059Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["visibility"],"created_at":"2024-07-31T05:01:29.078Z","updated_at":"2025-10-05T22:40:43.734Z","avatar_url":"https://github.com/vissense.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"[![Build Status](https://api.travis-ci.org/vissense/vissense.png?branch=master)](https://travis-ci.org/vissense/vissense)\n[![Test Status](https://saucelabs.com/buildstatus/vissense)](https://saucelabs.com/beta/builds/fe8f8b9ad75042fb875b4f3e0fd1e8f1)\n[![Coverage Status](https://coveralls.io/repos/vissense/vissense/badge.png)](https://coveralls.io/r/vissense/vissense)\n[![Dependency Status](https://david-dm.org/vissense/vissense.svg)](https://david-dm.org/vissense/vissense)\n[![devDependency Status](https://david-dm.org/vissense/vissense/dev-status.svg)](https://david-dm.org/vissense/vissense#info=devDependencies)\n[![Inline docs](http://inch-ci.org/github/vissense/vissense.svg?branch=master)](http://inch-ci.org/github/vissense/vissense)\n![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)\n\n![logo](https://raw.githubusercontent.com/vissense/vissense/master/vissense-logo.png)\n\nVisSense.js\n====\n\nA utility library for observing visibility changes of DOM elements.\nImmediately know when an element becomes hidden, partly visible or fully visible.\n\nVisSense.js is **lightweight** (\u003c4KB minified and gzipped), **tested** and **documented**. Best of all: **No dependencies**.\n\n#### What it does\n * provides methods for detecting visibility of DOM elements\n * provides a convenience class with straightforward methods like `isHidden`, `isVisible`, `isFullyVisible`, `percentage`\n * provides a convenience class for detecting changes in visibility\n\n#### What it does *not* do (by default)\n * detect if an element is overlapped by others\n * take elements opacity into account\n * take scrollbars into account - elements \"hidden\" behind scrollbars are considered visible\n\n\nDemos and Examples\n------------\nCheck out [this bin for a quick demo](https://jsbin.com/yoqopa/edit?js,console,output), [or here](https://jsbin.com/zegofij/edit?js,console,output).\nSee more examples on the [demo page](https://vissense.github.io/vissense-demo/).\n\nIn this simple example a video will only be started if at least 75% of its area is in the users viewport:\n```javascript\nvar video = $('#video'); \nvar videoVisibility = VisSense(video[0]);\n\nif(videoVisibility.percentage() \u003e 0.75) { \n  video.play();\n}\n```\n\nIn the following example the video will be started if it's at least 75% visible and stopped as soon as it is not visible anymore:\n```javascript\nvar video = $('#video'); \nvar visibility = VisSense(video[0], { fullyvisible: 0.75 });\n\nvar visibility_monitor = visibility.monitor({\n  fullyvisible: function() { \n    video.play();\n  }, \n  hidden: function() { \n    video.stop(); \n  }\n}).start();\n```\nSee a slightly adapted version of this example live and [try it on jsbin.com](https://jsbin.com/maqaco/edit?js,output).\n\nDocumentation\n------------\nSee [vissense.github.io/vissense](https://vissense.github.io/vissense/) or generate the documentation locally.\n\n#### Generate documentation\nClone the repository and run `grunt docs`\n\nDownload\n------------\n\n### npm\nInstall with [npm](https://www.npmjs.com/package/vissense)\n```\nnpm install vissense --save\n```\n\n### Bower\nInstall with bower\n```\nbower install vissense/vissense --save\n```\n\n### Github\n[Download from Github](https://github.com/vissense/vissense/releases)\n\n\n### cdnjs\n[Reference from cdnjs.com](https://cdnjs.com/libraries/vissense)\n\n\nContribute\n------------\n\n- Issue Tracker: https://github.com/vissense/vissense/issues\n- Source Code: https://github.com/vissense/vissense\n\n### Clone Repository\n`git clone https://github.com/vissense/vissense.git`\n\n#### Install dependencies\n```\nnpm install -g grunt-cli\nnpm install -g karma-cli\nnpm install -g bower\nnpm install\nbower install\n```\n\n#### Build project\n\n`grunt`\n\n#### Run tests\n\n`grunt test`\n\nor\n\n`grunt serve`\n\nand it automatically opens `http://localhost:3000/SpecRunner.html` in your browser.\n\n\nAPI\n------------\n\n### VisSense(element [, options])\n\nObject constructor. Options:\n\n- `hidden` (_default: 0_) - if percentage is equal or below this limit the element is considered hidden\n- `fullyvisible` (_default: 1_) -  if percentage is equal or above this limit the element is considered fully visible\n\nNote: you can omit `new` keyword when calling `VisSense(...)`\n\n#### .percentage()\n\ngets the current visible percentage (0..1)\n\n#### .isHidden()\n\n`true` if element is hidden\n\n#### .isVisible()\n\n`true` if element is visible\n\n#### .isFullyVisible()\n\n`true` if element is fully visible\n\n#### .state()\n\nreturns an object representing the current state\n\n```javascript\n{ \n  \"code\": 0, \n  \"state\": \"hidden\", \n  \"percentage\": 0, \n  \"visible\": false, \n  \"fullyvisible\": false, \n  \"hidden\": true,\n  \"previous\": {}\n}\n```\n\n#### .monitor([config])\n\nThis is an alias for getting a VisSense.VisMon object observing the current element. \nSee the options below for more details.\n\n```javascript\nvar element = document.getElementById('video');\n\nvar visibility_monitor = VisSense(element).monitor({\n  visible: function() { \n    console.log('visible');\n  }, \n  hidden: function() { \n    console.log('hidden');\n  }\n}).start();\n```\n\n### VisSense.VisMon(visobj [, options])\n\nA monitor object lets you observe an element over a period of time.\nIt emits certain events you can subscribe to, and it can be extended with custom logic.\n\nObject constructor. Options:\n\n- `strategy` a strategy (or array of strategies) for observing the element. VisSense comes with two predefined strategies. See below.\n- `start` function to run when monitoring the element starts\n- `stop` function to run when monitoring the element stops\n- `update` function to run when elements update function is called\n- `hidden` function to run when element becomes hidden\n- `visible` function to run when element becomes visible\n- `fullyvisible` function to run when element becomes fully visible\n- `visibilitychange` function to run when the visibility of the element changes\n- `percentagechange` function to run when the percentage of the element changes\n- `async` a boolean flag indicating whether events are synchronous or asynchronous\n\n```javascript\nvar visobj = VisSense(document.getElementById('video'));\n\nvar visibilityMonitor = VisSense.VisMon(visobj, { \n  strategy: [\n    new VisSense.VisMon.Strategy.EventStrategy({ throttle: 42 })\n  ],\n  visibilitychange: function() { \n    console.log('visibilitychange');\n  }, \n  visible: function() { \n    console.log('element became visible');\n  }\n}).start();\n```\n\n##### Strategies\nStrategies are hooks which let you intercept the monitoring process.\ne.g. updating the monitor, sending custom events, etc.\n\nVisSense comes with two predefined strategies:\n  - `PollingStrategy` a simple strategy which invokes `update()` periodically.\n  - `EventStrategy` this strategy registers event handlers for `visibilitychange`, `scroll` and `resize` events and calls `update()` accordingly.\n\nA monitor can use any number of strategies. The default monitor uses a combination of `EventStrategy` and `PollingStrategy`. Feel free to write your own strategy to cover your specific requirements (it's super easy).\nYou can also pass an empty array if you don't want to use any strategy.\n\n#### .start() \nstarts observing the element returns `this`\n\n#### .stop() \nstops observing the element\n\n#### .update() \nmanually run the update procedure. this will fire all registered hooks accordingly e.g. when a percentage change happened.\n\n#### .state() \nreturns a state object\n\n```javascript\n{ \n  \"code\": 1, \n  \"state\": \"visible\", \n  \"percentage\": 0.55, \n  \"visible\": true, \n  \"fullyvisible\": false, \n  \"hidden\": false \n  \"previous\" : { \n    \"code\": 2, \n    \"state\": \"fullyvisible\", \n    \"percentage\": 1, \n    \"visible\": true, \n    \"fullyvisible\": true, \n    \"hidden\": false \n  }\n} \n```\n\n#### .on(event, hook) \nregisters an event hook\n\n```javascript\nvisibility_monitor.on('percentagechange', function() { ... });\n```\n\n\n##### Builder\nThere is a builder available if you want to build more complex monitor objects.\n\n```javascript\nvar visobj = VisSense(document.getElementById('video'));\n\nvar visibilityMonitor = VisSense.VisMon.Builder(visobj)\n  .strategy(new VisSense.VisMon.Strategy.ConfigurablePollingStrategy({\n    hidden: 1000,\n    visible: 2000,\n    fullyvisible: 5000\n  }))\n  .strategy(new VisSense.VisMon.Strategy.EventStrategy({ throttle: 200 }))\n  .strategy(new VisSense.VisMon.Strategy.UserActivityStrategy({ inactiveAfter: 60000 }))\n  .strategy(new VisSense.VisMon.Strategy.PercentageTimeTestEventStrategy('50%/10s', { \n    percentageLimit: 0.5,\n    timeLimit: 10000,\n    interval: 100\n  }))\n  .strategy({\n    start: function(monitor) {\n      setTimeout(function() {\n        monitor.publish('mySpecialEvent');\n      }, 10000);\n    }\n  })\n  .on('start', function (monitor) {\n      console.log('[Visibility Monitor] Started!');\n  })\n  .on('stop', function (monitor) {\n    console.log('[Visibility Monitor] Stopped!');\n  })\n  .on('visible', function (monitor) {\n    console.log('[Visibility Monitor] Element became visible!');\n  })\n  .on('50%/10s', function (monitor) {\n    console.log('[Visibility Monitor] Element was \u003e50% visible for 10 seconds!');\n  })\n  .on('mySpecialEvent', function (monitor) {\n    console.log('[Visibility Monitor] MySpecialEvent received!');\n  })\n  .build()\n  .startAsync();\n```\nThis example uses external strategies. See [UserActivityStrategy](https://github.com/vissense/vissense-user-activity), [PercentageTimeTestEventStrategy](https://github.com/vissense/vissense-percentage-time-test) and [ConfigurablePollingStrategy](https://github.com/vissense/vissense-configurable-polling-strategy) for more information.\n\n\nLicense\n-------\n\nThe project is licensed under the MIT license. See\n[LICENSE](LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvissense%2Fvissense","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvissense%2Fvissense","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvissense%2Fvissense/lists"}