{"id":16793075,"url":"https://github.com/maxwroc/vanilla-pattern-lock","last_synced_at":"2025-11-02T17:01:47.858Z","repository":{"id":45491362,"uuid":"436399352","full_name":"maxwroc/vanilla-pattern-lock","owner":"maxwroc","description":"Android like pattern unlock","archived":false,"fork":false,"pushed_at":"2021-12-10T20:06:26.000Z","size":66,"stargazers_count":8,"open_issues_count":2,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-11T17:45:38.991Z","etag":null,"topics":["alarm-panel","android","pattern-lock"],"latest_commit_sha":null,"homepage":"https://maxwroc.github.io/vanilla-pattern-lock/","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/maxwroc.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":"2021-12-08T21:38:31.000Z","updated_at":"2025-03-03T18:49:13.000Z","dependencies_parsed_at":"2022-07-15T05:46:05.949Z","dependency_job_id":null,"html_url":"https://github.com/maxwroc/vanilla-pattern-lock","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":"maxwroc/typescript-project-boilerplate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxwroc%2Fvanilla-pattern-lock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxwroc%2Fvanilla-pattern-lock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxwroc%2Fvanilla-pattern-lock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxwroc%2Fvanilla-pattern-lock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maxwroc","download_url":"https://codeload.github.com/maxwroc/vanilla-pattern-lock/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxwroc%2Fvanilla-pattern-lock/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259256427,"owners_count":22829627,"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":["alarm-panel","android","pattern-lock"],"created_at":"2024-10-13T08:48:06.010Z","updated_at":"2025-11-02T17:01:47.776Z","avatar_url":"https://github.com/maxwroc.png","language":"TypeScript","readme":"# vanilla-pattern-lock\n[![npm](https://img.shields.io/npm/dm/vanilla-pattern-lock?label=npm%20downloads)](https://www.npmjs.com/package/vanilla-pattern-lock)\n[![npm version](https://img.shields.io/npm/v/vanilla-pattern-lock?color=blue)](https://www.npmjs.com/package/vanilla-pattern-lock)\n\nAndroid like pattern unlock.\n\n## Features\n\n* Converts pattern to number\n* Vanilla JS - no external libs required\n* Support for touch devices\n* Small size (less than 10KB)\n* TS typings\n\n![pattern-lock2-ffmpg](https://user-images.githubusercontent.com/8268674/145471565-15d1bc26-fb09-4471-9cf7-a699f378762e.gif)\n\n## Demo\n\nhttps://maxwroc.github.io/vanilla-pattern-lock/\n\n## Usage\n\n```javascript\nconst lock = new PatternLock({ \n    vibrate: true // whether to vibrate on dot/node selection (mobile devices)\n});\n\nlock\n  .render(document.getElementById(\"lockContainer\"))\n  .on(\"complete\", pattern =\u003e { // triggers when user stops swiping\n      if (pattern == 12345) {\n          lock.success(); // green markers\n      }\n      else {\n          lock.failure(); // red markers\n          setTimeout(() =\u003e {\n              lock.clear();\n          }, 2000);\n      }\n  })\n```\n\n## Documentation\n\n### Methods\n\n| Method interface | Return value | Description |\n|:-----|:-----|:-----|\n| `render(container: Element)` | `PatternLock` | Renders pattern lock SVG element\u003cbr\u003e`container` - Element in which SVG will be rendered\n| `clear()` | `PatternLock` | Clears existing selection and resets internal state\n| `getPattern()` | `number` | Returns current pattern\n| `success()` | `PatternLock` | Shows success markers/indicators\n| `failure()` | `PatternLock` | Shows failure markers/indicators\n\nEvent related methods\n\n| Method interface | Return value | Description |\n|:-----|:-----|:-----|\n| `on(name: string, func: Function)` | `PatternLock` | Sets handler for an event (for handler interface look below)\n| `off(name: string, func: Function)` | `PatternLock` | Removes handler for an event\n\n### Events\n\n| Event name | Handler interface | Description |\n|:-----|:-----|:-----|\n| `complete` | `(pattern: number): void` | Fired when user finished entering pattern\n| `select` | `(index: number, elem: Element): void` | Fired when the dot/node is selected.\u003cbr\u003e`index` - Index of the dot/node\u003cbr\u003e`elem` - Dot element (SVG image element)\n| `selectionStart` | `(): void` | Fired when user starts entering pattern\n| `selectionEnd` | `(): void` | Fired when user ends entering pattern\n| `clear` | `(): void` | Fired when clear method is called (current pattern is erased)\n\n### Settings\n\n| Name | Type | Description |\n|:-----|:-----|:-----|\n| vibrate | `boolean` | Whether to vibrate when dot is selected\n\n## Installation / download\n\n* Install via NMP\n\n  ```\n  npm install vanilla-pattern-lock\n  ```\n\n* Github releases: [vanilla-pattern-lock/releases](https://github.com/maxwroc/vanilla-pattern-lock/releases)\n\n## Like it? Star it!\n\nIf you like it please consider leaving star on github.\n\n## Credits\n\nThis code is based on [Tympanix/pattern-lock-js](https://github.com/Tympanix/pattern-lock-js). The original library depends on JQuery and it is written in plain JS. I have rewritten the original code in TypeScript and I've added few additional features.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxwroc%2Fvanilla-pattern-lock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaxwroc%2Fvanilla-pattern-lock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxwroc%2Fvanilla-pattern-lock/lists"}