{"id":13827206,"url":"https://github.com/umanghome/swipe-listener","last_synced_at":"2026-01-21T05:05:10.090Z","repository":{"id":29817810,"uuid":"122840893","full_name":"umanghome/swipe-listener","owner":"umanghome","description":"Zero-dependency, minimal swipe-gesture listener for the web.","archived":false,"fork":false,"pushed_at":"2024-08-25T18:37:46.000Z","size":417,"stargazers_count":107,"open_issues_count":7,"forks_count":11,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-02T18:39:23.115Z","etag":null,"topics":["event-listener","gestures","javascript","swipe","swipe-gestures","touch","web"],"latest_commit_sha":null,"homepage":"https://umanghome.github.io/swipe-listener","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/umanghome.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"publiccode":null,"codemeta":null}},"created_at":"2018-02-25T13:58:43.000Z","updated_at":"2025-08-16T12:11:59.000Z","dependencies_parsed_at":"2024-11-20T06:31:19.334Z","dependency_job_id":"c61c4706-1d3a-4a6c-bfd6-e125e063a4ce","html_url":"https://github.com/umanghome/swipe-listener","commit_stats":{"total_commits":39,"total_committers":7,"mean_commits":5.571428571428571,"dds":0.5128205128205128,"last_synced_commit":"a933014678377ad8b49c4f8b26ef99010f3f9f59"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/umanghome/swipe-listener","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umanghome%2Fswipe-listener","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umanghome%2Fswipe-listener/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umanghome%2Fswipe-listener/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umanghome%2Fswipe-listener/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/umanghome","download_url":"https://codeload.github.com/umanghome/swipe-listener/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umanghome%2Fswipe-listener/sbom","scorecard":{"id":908314,"data":{"date":"2025-08-11","repo":{"name":"github.com/umanghome/swipe-listener","commit":"4cc517b48cd98bcd5916e30b919af84464b99e64"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.8,"checks":[{"name":"Code-Review","score":1,"reason":"Found 2/12 approved changesets -- score normalized to 1","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":"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":"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":"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":"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":"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":"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":"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":0,"reason":"Project has not signed or included provenance with any releases.","details":["Warn: release artifact v1.1.0 not signed: https://api.github.com/repos/umanghome/swipe-listener/releases/18475543","Warn: release artifact v1.1.0 does not have provenance: https://api.github.com/repos/umanghome/swipe-listener/releases/18475543"],"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":3,"reason":"branch protection is not maximal on development and all release branches","details":["Info: 'allow deletion' disabled on branch 'master'","Info: 'force pushes' disabled on branch 'master'","Info: 'branch protection settings apply to administrators' is required to merge on branch 'master'","Warn: 'stale review dismissal' is disabled on branch 'master'","Warn: branch 'master' does not require approvers","Warn: codeowners review is not required on branch 'master'","Warn: 'last push approval' is disabled on branch 'master'","Warn: no status checks found to merge onto branch 'master'","Info: PRs are required in order to make changes on branch 'master'"],"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 25 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":7,"reason":"3 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp"],"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-24T18:12:59.216Z","repository_id":29817810,"created_at":"2025-08-24T18:12:59.216Z","updated_at":"2025-08-24T18:12:59.216Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28627388,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-21T04:47:28.174Z","status":"ssl_error","status_checked_at":"2026-01-21T04:47:22.943Z","response_time":86,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["event-listener","gestures","javascript","swipe","swipe-gestures","touch","web"],"created_at":"2024-08-04T09:01:52.052Z","updated_at":"2026-01-21T05:05:10.074Z","avatar_url":"https://github.com/umanghome.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# Swipe-Listener\n\n[![npm version](https://badge.fury.io/js/swipe-listener.svg)](https://www.npmjs.com/package/swipe-listener)\n\nZero-dependency, minimal swipe-gesture listener for the web.\n\n---\n\n## [Demo](https://umanghome.github.io/swipe-listener)\n\n# What\n\nSwipe-listener is a very minimal library that allows listening for swipe gesture on literally any DOM element. Once invoked with a DOM element, simply listen for `swipe` event and determine the direction with the `directions` object.\n\n# Example Code\n\n```js\nvar container = document.querySelector('#container');\nvar listener = SwipeListener(container);\ncontainer.addEventListener('swipe', function (e) {\n  var directions = e.detail.directions;\n  var x = e.detail.x;\n  var y = e.detail.y;\n\n  if (directions.left) {\n    console.log('Swiped left.');\n  }\n\n  if (directions.right) {\n    console.log('Swiped right.');\n  }\n\n  if (directions.top) {\n    console.log('Swiped top.');\n  }\n\n  if (directions.bottom) {\n    console.log('Swiped bottom.');\n  }\n\n  if (directions.top \u0026\u0026 directions.right) {\n    console.log('Swiped top-right.');\n  }\n\n  if (directions.top \u0026\u0026 directions.left) {\n    console.log('Swiped top-left.');\n  }\n\n  if (directions.bottom \u0026\u0026 directions.right) {\n    console.log('Swiped bottom-right.');\n  }\n\n  if (directions.bottom \u0026\u0026 directions.left) {\n    console.log('Swiped bottom-left.');\n  }\n\n  console.log('Started horizontally at', x[0], 'and ended at', x[1]);\n  console.log('Started vertically at', y[0], 'and ended at', y[1]);\n});\n```\n\n# Installation\n\n## Browser\n\n```html\n\u003cscript src=\"path/to/swipe-listener.min.js\" type=\"text/javascript\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n  var container = document.querySelector('#container');\n  var listener = SwipeListener(container);\n  container.addEventListener('swipe', function (e) {\n    console.log(e.detail);\n  });\n\u003c/script\u003e\n```\n\nSwipe-listener is also available from unpkg: [`https://unpkg.com/swipe-listener@1.3.1/dist/swipe-listener.min.js`](https://unpkg.com/swipe-listener@1.3.1/dist/swipe-listener.min.js)\n\n## Installing using NPM\n\nInstall from NPM using `npm i --save swipe-listener`, then\n\n```js\nimport SwipeListener from 'swipe-listener';\n```\n\nOR\n\n```js\nconst SwipeListener = require('swipe-listener');\n```\n\n# API\n\n### `SwipeListener(element, options)`\n\n- `element` DOM Element on which you want to enable swipe gesture tracking. This is the element on which you will be attacking the `swipe` event listener.\n- `options` [Optional] Configuration options (see below)\n\nListen for `swipe` event on the `element` passed. Access details using `event.detail`. For example, `directions` can be accessed using `event.detail.directions`. See [events](#events) for more events.\n\nData passed to `event.detail`:\n\n- `directions` (Object)\n  - `top` (Boolean) Signifies a top-swipe.\n  - `right` (Boolean) Signifies a right-swipe.\n  - `bottom` (Boolean) Signifies a bottom-swipe.\n  - `left` (Boolean) Signifies a left-swipe.\n- `x` (Array) Array containing two elements: starting and ending x-coords.\n- `y` (Array) Array containing two elements: starting and ending y-coords.\n- `touch` (Boolean) Whether or not `TouchEvent` was used for this particular event.\n\n**Note that multiple directions can be `true` at one. In case of a top-left swipe, `directions.top` and `directions.left` will both be `true`.**\n\n### Options\n\n| Key               | Description                                                                                                                                                                                                                                   | Default value |\n| ----------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- |\n| `minHorizontal`   | Minimum number of horizontal pixels travelled for the gesture to be considered as a left or right swipe.                                                                                                                                      | `10`          |\n| `minVertical`     | Minimum number of vertical pixels travelled for the gesture to be considered as a top or bottom swipe.                                                                                                                                        | `10`          |\n| `deltaHorizontal` | Maximum difference between the rightmost pixel (right-swipe) or the leftmost pixel (left-swipe) travelled to and the pixel at which the gesture is released.                                                                                  | `3`           |\n| `deltaVertical`   | Maximum difference between the bottommost pixel (bottom-swipe) or the topmost pixel (top-swipe) travelled to and the pixel at which the gesture is released.                                                                                  | `5`           |\n| `preventScroll`   | Prevents page scrolling when swiping on the DOM element. Can also be specified as a function with the signature `(event) =\u003e boolean`                                                                                                          | `false`       |\n| `lockAxis`        | Enforces only one direction to be true instead of multiple. Selects the direction with the most travel. Is not enforced when the travel is equal. Example: for a top-left swipe, only one of `top` and `left` will be `true` instead of both. | `true`        |\n| `touch`           | Whether to listen for swipes with touch events                                                                                                                                                                                                | `true`        |\n| `mouse`           | Whether to listen for swipes with mouse events                                                                                                                                                                                                | `true`        |\n\n### `.off()`\n\nTurns off the swipe-listener on a given element.\n\nUsage:\n\n```js\nvar listener = SwipeListener(myElem);\nlistener.off();\n```\n\n# Events\n\n### `swipe` - Emitted once a swipe is performed.\n\nEmitted once a swipe is completed.\n\n`event.detail` contains\n\n| key          | type    | description                                                                                                                |\n| ------------ | ------- | -------------------------------------------------------------------------------------------------------------------------- |\n| `directions` | Object  | Object containing `top`, `left`, `bottom`, `right` keys. The directions in which the swipe is performed are set to `true`. |\n| `x`          | Array   | Array of two items: the starting x-coordinate and the ending x-coordinate.                                                 |\n| `y`          | Array   | Array of two items: the starting y-coordinate and the ending y-coordinate.                                                 |\n| `touch`      | Boolean | Whether or not `TouchEvent` was used for this particular event.                                                            |\n\n### `swiping` - Emitted while a swipe is being performed.\n\nEmitted multiple times during a single swipe.\n\n`event.detail` contains\n\n| key     | type    | description                                                                |\n| ------- | ------- | -------------------------------------------------------------------------- |\n| `x`     | Array   | Array of two items: the starting x-coordinate and the ending x-coordinate. |\n| `y`     | Array   | Array of two items: the starting y-coordinate and the ending y-coordinate. |\n| `touch` | Boolean | Whether or not `TouchEvent` was used for this particular event.            |\n\n### `swiperelease` - Emitted once the swipe is released/completed.\n\nEmitted at the end of the swipe.\n\n`event.detail` contains\n\n| key     | type    | description                                                                |\n| ------- | ------- | -------------------------------------------------------------------------- |\n| `x`     | Array   | Array of two items: the starting x-coordinate and the ending x-coordinate. |\n| `y`     | Array   | Array of two items: the starting y-coordinate and the ending y-coordinate. |\n| `touch` | Boolean | Whether or not `TouchEvent` was used for this particular event.            |\n\n### `swipecancel` - Emitted if the swipe-distance did not meet minimum travel-distance.\n\nEmitted at the end of the swipe.\n\n`event.detail` contains\n\n| key     | type    | description                                                                |\n| ------- | ------- | -------------------------------------------------------------------------- |\n| `x`     | Array   | Array of two items: the starting x-coordinate and the ending x-coordinate. |\n| `y`     | Array   | Array of two items: the starting y-coordinate and the ending y-coordinate. |\n| `touch` | Boolean | Whether or not `TouchEvent` was used for this particular event.            |\n\n# Misc\n\n- When `lockAxis` is `false`, swipes using the mouse might make multiple directions `true` even when the travel in a certain direction may not be much. You can work around this by setting `lockAxis` to `true` when the page is not being accessed from a touch-enabled device. Or, you can use `event.detail.x` and `event.detail.y` to calculate which direction has more travel and consider only that direction. Or, you can increase the values of `minVertical` and `minHorizontal`.\n- [`TouchEvent`](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent/TouchEvent) is not supported in IE and Edge. Unless you have polyfilled it into the page and it's available as `TouchEvent`, swipes made using touch will not be detected as touch swipes.\n\n---\n\n# License\n\n[MIT License](https://opensource.org/licenses/MIT) © [Umang Galaiya](https://umanggalaiya.in/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fumanghome%2Fswipe-listener","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fumanghome%2Fswipe-listener","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fumanghome%2Fswipe-listener/lists"}