npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-pattern-lock

v12.0.12

Published

Android's pattern lock

Downloads

1,294

Readme

React-Pattern-Lock

Lint & Test

Android's pattern lock

  • Supports multiple sizes. eg : 2x2, 3x3, 4x4 -- 15x15.
  • Supports touch screens.
  • Many options to customize the input.

Edit n5j7knjo54

Installation

npm install react-pattern-lock

How to use

import React, { Component } from "react";
import PatternLock          from "react-pattern-lock";

// in you render method
<PatternLock
	width={ 300 }
	pointSize={ 15 }
	size={ 3 }
	path={ this.state.path }
	onChange={ (pattern) => {
		this.setState({ path : pattern });
	}}
	onFinish={() => {
		// check if the pattern is correct
	}}
/>

Props

| Prop | Type | Default | Definition | | --- | --- | --- | --- | | size | Number | 3 | The size of the pattern input. | | width | Number, String | "100%" | The width of the pattern wrapper. | | disabled | Boolean | false | Disables the pattern input. | | invisible | Boolean | false | Makes the lines that connect the points invisible. | | noPop | Boolean | false | Disables the pop animation when a point gets activated. | | onChange | Function | (path: number[]) => void | A Function (the first argument is the drawn path). | | path | number[] | [] | The drawn path. | | allowJumping | Boolean | false | Setting this to true would disable the auto activation on points that are in the middle of 2 already activated points (see details below). | | allowOverlapping | Boolean | false | Allows you to select the same point multiple times (Doesn't show the pop animation on the second time). | | pointSize | Number | 10 | The size of the pattern points (used for width and height) in pixels. | | pointActiveSize | Number | 30 | The size (in pixels) of the active area of the pattern points. | | connectorThickness | Number | 2 | The thickness (in pixels) of the lines that connect the points. | | connectorRoundedCorners | Boolean | false | Setting this to true makes the connector edges rounded. | | className | String | "" | Any css classes that you might want to send to the wrapper. | | success | Boolean | false | Will add "success" class to the wrapper, it will also make the points and the connectors green | | error | Boolean | false | Will add "error" class to the wrapper, it will also make the points and the connectors red | | style | Object | {} | Any css styles that you might want to send to the wrapper. |


Pattern Representation

A pattern path is represented as an array of numbers. for example :
in a 3x3 pattern the points are numbered starting from 0 top left, and ending in 8 bottom right.

react-pattern-lock

So for example :

react-pattern-lock

This would result in an array like this [1, 3, 4, 0].


Detailed Props

size Number default : 3

The size of the pattern input

  • 3 is 3x3 (9 points in total).
  • 4 is 4x4 (16 points in total).
  • etc.

allowJumping Boolean default : false

Setting this property to true would allow you to connect 2 points that have unselected points between them (diagonally, vertically or horizontally) without the points in the middle being auto selected for you (see image below).

react-pattern-lock

disabled Boolean default : false

Makes the pattern input disabled (turns gray and user input is disabled).

react-pattern-lock

invisible Boolean default : false

Hides the lines that connect the pattern points.

react-pattern-lock

noPop Boolean default : false

Disables the pop animation when a point gets activated.

react-pattern-lock

pointActiveSize Number default : 30

The active area of each of the points.
When the cursor enters this area the point will be activated.

Activate areas are indicated by the blue squares.

react-pattern-lock

Extra

You can override the default colors for (disabled, success, error) using css Check the codepen example for more info

Edit n5j7knjo54

License

MIT Licensed. Copyright (c) WinterCore 2019.