{"id":13821901,"url":"https://github.com/hex2f/xnap","last_synced_at":"2025-04-14T20:52:52.452Z","repository":{"id":47803470,"uuid":"197795712","full_name":"hex2f/xnap","owner":"hex2f","description":"👌 Components that snap.","archived":false,"fork":false,"pushed_at":"2023-01-07T22:31:26.000Z","size":5586,"stargazers_count":26,"open_issues_count":9,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-05-19T11:09:41.543Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://leahlundqvist.github.io/xnap/","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/hex2f.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":"2019-07-19T15:13:57.000Z","updated_at":"2023-08-23T12:40:14.000Z","dependencies_parsed_at":"2023-02-08T02:48:59.863Z","dependency_job_id":null,"html_url":"https://github.com/hex2f/xnap","commit_stats":null,"previous_names":["leahlundqvist/xnap"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hex2f%2Fxnap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hex2f%2Fxnap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hex2f%2Fxnap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hex2f%2Fxnap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hex2f","download_url":"https://codeload.github.com/hex2f/xnap/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248681492,"owners_count":21144700,"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-08-04T08:01:33.109Z","updated_at":"2025-04-14T20:52:52.433Z","avatar_url":"https://github.com/hex2f.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# Xnap\n\nComponents that snap.\n\n## Demo\n[https://memeone.github.io/xnap/](https://memeone.github.io/xnap/)\n\n![Demo Gif](./demo.gif)\n\n```\nnpm i --save xnap\n```\n\n## How do i use it?\n\nFor a full example, check out /example.\nHere's a simple example that snaps between `transformX(-100%)` and `transformX(100%)`.\n\n```js\nlet xnapCard = new Xnap(component, { states: ['-100% + ', '100% + '], direction: 0 })\nxnapCard.register() // Register the event listeners.\n```\n\n## Options\n\n```js\nnew Xnap(component, { options })\n```\n\n| Name        | Type         | Default              | Description                                                                                                              |\n|-------------|--------------|----------------------|--------------------------------------------------------------------------------------------------------------------------|\n| exact       | Boolean      | false                | If dragging should only be triggered when you touch the component xnap was mounted on.                                   |\n| state       | Boolean      | false                | Which state the component is initiated with.                                                                             |\n| states      | String Array | ['0% + ', '100% + '] | What the transforms are for the states. Movement is appended to the current string.                                      |\n| scaleStates | Number Array | [1.0, 1.0]           | What the scales are for the states.                                                                                      |\n| factor      | Number       | 5                    | How snappy it is. Higher = Snappier.                                                                                     |\n| length      | Number       | 100                  | How far it needs to be dragged before it snaps.                                                                          |\n| onTrue      | Function     | None                 | Function that triggers when state is set to true.                                                                        |\n| onFalse     | Function     | None                 | Function that triggers when state is set to false.                                                                       |\n| condition   | Function     | () =\u003e true           | Runs on mouse/touch down, if false return: don't trigger moving.                                                         |\n| direction   | Number       | 1                    | Which direction it moves. 0 = Left/Right. 1 = Up/Down.                                                                   |\n| vibrate     | Number       | None                 | If a number is given, it vibrates the device on state change for the given duration in MS. Use 2 - 5 for a clicky tap.   |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhex2f%2Fxnap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhex2f%2Fxnap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhex2f%2Fxnap/lists"}