New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

jestures

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jestures

A (hopefully it stays) small web gesture library.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

jestures

A (hopefully it stays) small web gesture library.

Installing

npm install jestures -S
yarn jestures

Usage

on('swipe')((swipeEvent) => { console.log('swiped ', swipeEvent.detail.direction) })

on

eventName -> callback -> target -> off The on function is the only exposed function. See Gestures for the gesture events that can be listened for.

Gestures

tap

The tap event is what is wanted most of the time you want to react to a user 'click' on an element. It bypasses the usual 300 millisecond delay and makes your app feel more responsive.

const offTap = on('tap')((tapEvent) => {
  console.log(`just ${swipeEvent.type} it in. `)
  offTap()
})

double-tap

The double-tap event is fired when the user taps twice in succession within 300ms. It should be noted that a double-tap event will be preceded by two tap events.

const offDoubleTap = on('double-tap')((tapEvent) => {
  console.log(`just ${swipeEvent.type} it in. `)
  offDoubleTap()
})

single-tap

There may be occasions where a single tap needs to be distinguished from a double-tap. Usually, this only happen when a single tap and a double-tap each have distinctly different meanings and different actions need to be taken for each of them respectively. In those case, using the tap event would be less helpful. Instead, use the single-tap which uses the default experience of a 300ms delay before firing the event to ensure the tap in not just the first tap of a double tap gesture.

const offSingleTap = on('single-tap')((singleTapEvent) => {
  console.log(`This is ${singleTapEvent.type}`)
  offSingleTap()
})

swipe

The swipe event fires whenever the user moves a touch more than 50px in either ordinal direction. The event includes a detail object with a direction property that has a value of either up, down, left, or right depending on which direction was the greatest.

const offSwipe = on('swipe')((swipeEvent) => {
  console.log('swiped ', swipeEvent.detail.direction)
  offSwipe()
})

pinch

The pinch event fires when a touchmove event happen with exactly two touch points originating from the same target element. The pinch event also has a detail object with a distance property that gives the distance between the two touch points. This is useful to map the scale of an element to the motion and growth of the gesture, or to determine whether the gesture is pinching - the distance between the touch points is diminishing - or spreading - the distance between touch points is growing.

FAQs

Package last updated on 09 Feb 2017

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