Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

any-touch

Package Overview
Dependencies
Maintainers
1
Versions
149
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

any-touch

一个手势库

  • 0.0.21
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
310
decreased by-26.71%
Maintainers
1
Weekly downloads
 
Created
Source

any-touch NPM Version NPM Downloads npm bundle size (minified + gzip) codecov CircleCI

:wave: 一个手势库

演示

查看

安装

npm i -S any-touch

使用

基础

import AnyTouch from 'any-touch';

// 初始化
const el = doucument.getElementById('gesture-box');
const at = new AnyTouch(el);

// 绑定手势
at.on('pan', ev=>{
  console.log(ev.deltaX);
})

// 解除绑定
at.off('pan')

// 销毁
at.destory();

自定义识别器

// 自定义一个双击识别器
const tap2 = new AnyTouch.TapRecognizer({
    name: 'doubletap',
    pointer: 1,
    taps: 2
});

// 添加自定义手势 
const el = doucument.getElementById('gesture-box');
const at = new AnyTouch(el);
at.add(tap2);
at.on('tap2', ev=>{
  console.log(ev);
});

// 一般情况下不期望双击时触发单击, 
// 所以要声明单击的触发一定要等待(一段时间内)双击没有触发(失败)才可以
const tap1 = anyTouch.get('tap');
tap1.requireFailure(tap2);

支持

  • 支持手势: tap | doubletap | pan | swipe | pinch | rotate.
  • 支持鼠标(mouse)
  • 手势互斥(requireFailure)
  • 自定义识别器(Recognizer)

FAQs

Package last updated on 19 Jan 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc