Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tympanix/pattern-lock-js

An android inspired pattern lock in scalable vector graphics and pure javascript
https://github.com/tympanix/pattern-lock-js

android authentication javascript pattern-lock smartphone svg tablet touch web

Last synced: 13 days ago
JSON representation

An android inspired pattern lock in scalable vector graphics and pure javascript

Awesome Lists containing this project

README

        

# pattern-lock-js
A passcode mechanism built with scalable vector graphics (SVG) and javascript for modern web application with mobile and tablet support

## [Demo](https://tympanix.github.io/pattern-lock-js/)

## Install
Install using npm:
```
npm i pattern-lock-js --save
```

... or install using yarn:
```
yarn add pattern-lock-js
```

## Getting started
Import dependecies:
```html

```
Import the module:
```html

```

Design your desired svg pattern (or use the default one below). Your svg graphics must as a minimum have the `patternlock` class and three groups `` with the classes `lock-actives`, `lock-lines` and `lock-dots`
```html











```
Initialise the component
```javascript
var lock = new PatternLock("#lock", {
onPattern: function(pattern) {
// Context is the pattern lock instance
console.log(pattern)
}
});
```

## Options
The returned object from `new PatternLock(...)` has the following utility functions:
* **`clear()`** Clears the current pattern
* **`success()`** Validates the pattern as correct
* **`error()`** Validates the pattern as incorrect
* **`getPattern()`** Returnes the currently active pattern or `NaN`

The pattern lock constructor accepts a second argument - an object literal with the following properties:

* **`onPattern: function`** Called when a pattern is drawn with the pattern as argument. Returning true/false validates/invalidates the pattern - the same as calling `success()` and `error()`. The context is set to the pattern lock instance itself.
* **`vibrate: boolean`** Defines if there should be vibrations while using the PatternLock (if available). Default: `true`