Code Monkey home page Code Monkey logo

weblock's Introduction

Web图案锁

介绍

基于html5的触摸图案锁。由于考虑到canvas在手机端的性能略差,并且使用canvas清晰度会有所降低,所以这里用div作为基本组件,重新封装了直线和圆的绘制方法。将直线和圆方法提供给Canvas组件,再在Canvas上封装了一层WebLock,最终使用WebLock作为构建的组件。

预览

Quick Start

  • 初始化

    //使用WebLock类
    var wl = new WebLock(document.querySelector('body'));
    wl.start();
    
  • 绘制结束后事件

    //只能有一个结束事件,下一个结束事件会覆盖上一个结束事件
    wl.done(function(password){ 
         console.log(password);//sample:[1,2,3,4,5];
    })
    
  • 简单配置

    //三个配置选项,直线样式,圆普通状态时样式,圆经过时样式
     wl.config({
          line:{
              background:'black',
              height:'10px',
              'border-radius':"10px"
          },
          circle:{
              background:'white',
              border:'1px solid grey'
          },
          active:{
              background:'red',
              border:'1px solid grey'
          }
     });
    

目录结构

  • /dist webpack最终打包压缩后的文件
  • /src 各种组件文件
  • /test 测试文件

构建

$   npm install 
$   webpack -p

调试开发

$ webpack-dev-server

打开http://localhost:8888 进行调试

测试

$ mocha     

Demo

请访问 https://cctv1005s.github.io/ (暂时删除了Demo) 仅支持手机端,浏览器端请开启手机调试模式

weblock's People

Contributors

cctv1005s avatar

Stargazers

 avatar lucky boy avatar  avatar ishida avatar  avatar

Watchers

James Cloos avatar  avatar lucky boy avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.