UNPKG

4.95 kBMarkdownView Raw
1<h1 align="center">RVerify.js</h1>
2<div align="center">
3
4✅❎ A lightweight image rotation verification plugin.
5
6![Build](https://img.shields.io/badge/build-passing-brightgreen?style=flat-square) ![Downloads](https://img.shields.io/npm/dt/rverify?style=flat-square&color=red) ![Version](https://img.shields.io/github/package-json/v/zpfz/RVerify.js?style=flat-square&color=orange) ![License](https://img.shields.io/github/license/zpfz/RVerify.js?style=flat-square&color=blue)
7
8</div>
9
10## Installation
11Add `RVerify.js` and `RVerify.css` to your project.
12```js
13<script src="RVerify.js"></script>
14<link rel="stylesheet" href="RVerify.css"/>
15```
16You can get the corresponding CDN link from [unpkg](https://unpkg.com/rverify/) or [jsdelivr](https://cdn.jsdelivr.net/gh/zpfz/RVerify.js/dist/).
17
18RVerify.js is available via [npm](https://www.npmjs.com/package/rverify).
19```sh
20npm install --save rverify
21```
22
23## Basic usage
24Simply call `action()` to activate the verification modal.
25```js
26RVerify.action(function(res){
27 console.log(res);
28});
29```
30`res` will return 3 different codes:
31
32- `0`: Verify failed.
33- `1`: Verify successful.
34- `2`: No action.(Return the code when the modal is closed before it successfully verified.)
35
36## Configuration
37You can configure some parameters through `RVerify.configure({})`.
38
39### mask
40Type: `Number`
41Default: `0.5`
42
43Set the mask transparency.
44```js
45RVerify.configure({
46 mask: 0.5
47})
48```
49
50### maskClosable
51Type: `Boolean`
52Default: `false`
53
54Set whether click the mask can be closed.
55```js
56RVerify.configure({
57 maskClosable: true
58})
59```
60### closeIcon
61Type: `String`
62Default: `(SVG CODE)`
63
64Set the modal close icon.
65```js
66RVerify.configure({
67 closeIcon: '(Please copy the SVG code)'
68})
69```
70**NOTE**: It's recommended to set the SVG icon `width` and `height` to `20px`.
71
72### sliderIcon
73Type: `String`
74Default: `(SVG CODE)`
75
76Set the modal slider icon.
77```js
78RVerify.configure({
79 sliderIcon: '(Please copy the SVG code)'
80})
81```
82**NOTE**: It's recommended to set the SVG icon `width` and `height` to `20px`.
83
84### extraIcon
85Type: `String`
86Default: `(SVG CODE)`
87
88Set the modal extra icon.
89```js
90RVerify.configure({
91 extraIcon: '(Please copy the SVG code)'
92})
93```
94**NOTE**: It's recommended to set the SVG icon `width` and `height` to `15px`.
95
96### tolerance
97Type: `Number`
98Default: `10`
99
100Set the verification tolerance range.(Range: 5°~45°)
101```js
102RVerify.configure({
103 tolerance: 10
104})
105```
106**NOTE**: In order to ensure a friendly verification effect, its value ranges from 5° to 45°.
107
108### duration
109Type: `Number`
110Default: `500`
111
112Set the modal delay closing time.(Unit: ms)
113```js
114RVerify.configure({
115 duration: 1000
116})
117```
118
119### title
120Type: `String`
121Default: `身份验证`
122
123Set the modal title.
124```js
125RVerify.configure({
126 title: 'Authentication'
127})
128```
129
130### text
131Type: `String`
132Default: `拖动滑块,使图片角度为正`
133
134Set the modal text.
135```js
136RVerify.configure({
137 text: 'Drag the slider to make the image angle positive.'
138})
139```
140
141### extra
142Type: `String`
143Default: `null`
144
145Set extra features at the bottom of the modal.
146```js
147RVerify.configure({
148 extra: 'View on Npm'
149})
150```
151
152### extraColor
153Type: `String`
154Default: `#4E6EF2`
155
156Set extra features text color at the bottom of the modal.
157```js
158RVerify.configure({
159 extraColor: '#1ca280'
160})
161```
162
163### extraLink
164Type: `String`
165Default: `https://github.com/zpfz`
166
167Set extra features link at the bottom of the modal.
168```js
169RVerify.configure({
170 extraLink: 'https://www.npmjs.com/package/rverify'
171})
172```
173
174### zIndex
175Type: `Number`
176Default: `9999`
177
178Set the modal z-index.
179```js
180RVerify.configure({
181 zIndex: 1000
182})
183```
184
185### album
186Type: `Array`
187Default: `[]`
188
189Set the modal randomly displayed image album.
190```js
191RVerify.configure({
192 album: [
193 'https://rverify.vercel.app/assets/1.jpg',
194 'https://rverify.vercel.app/assets/2.jpg',
195 'https://rverify.vercel.app/assets/3.jpg',
196 'https://rverify.vercel.app/assets/4.jpg',
197 'https://rverify.vercel.app/assets/5.jpg',
198 'https://rverify.vercel.app/assets/6.jpg',
199 'https://rverify.vercel.app/assets/7.jpg',
200 'https://rverify.vercel.app/assets/8.jpg',
201 'https://rverify.vercel.app/assets/9.jpg',
202 'https://rverify.vercel.app/assets/10.jpg'
203 ]
204})
205```
206**NOTE**: An image needs to be set at least.
207
208## Contributors
209This project exists thanks to all the people who contribute.
210
211![Feng L.H.](https://avatars2.githubusercontent.com/u/49757965?s=60&v=4) ![Guojun Chen](https://avatars2.githubusercontent.com/u/10856371?s=60&v=4) ![WampyCakes](https://avatars.githubusercontent.com/u/9156604?s=460&u=48e7338d3c8083644bfa242a592cb2b457a36aa5&v=4)
212
213
214## License
215RVerify © 2020-present, Feng L.H. Released under the [MIT License](https://mit-license.org/).
\No newline at end of file