Socket
Socket
Sign inDemoInstall

@seregpie/claw

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @seregpie/claw

A very small gesture recognizer.


Version published
Weekly downloads
131
increased by40.86%
Maintainers
1
Install size
8.66 kB
Created
Weekly downloads
 

Readme

Source

Claw

A very small gesture recognizer.

demo

Try it out!

setup

npm

npm install @seregpie/claw

ES module

import Claw from '@seregpie/claw';

browser

<script src="https://unpkg.com/@seregpie/claw"></script>

members

.constructor(target, {
  delay = 500,
  distance = 1,
})
argumentdescription
targetThe target element.
delayThe delay threshold to separate the event types.
distanceThe distance threshold to separate the event types.
let element = document.getElementById('claw');
(new Claw(element))
  .on('panStart', event => {
    // handle
  })
  .on('pan', event => {
    // handle
  })
  .on('panEnd', event => {
    // handle
  });

.on(type, listener)

chainable

Binds a listener to an event type.

claw.on('tap', event => {
  // handle tap event
});

.off(type, listener)

chainable

Unbinds a listener from an event type. Omit the argument listener to unbind all listeners from an event type. Omit the argument type to unbind all listeners from all event types.

let tapListener = function(event) {
  // handle tap event
  claw.off('tap', tapListener);
};
claw.on('tap', tapListener);

.isIdle

Returns true, if there are no bound listeners.

events

holdStart

{
  pointerType,
  timeStamp,
  x,
  y,
}

holdEnd

{
  initialTimeStamp,
  pointerType,
  timeStamp,
  x,
  y,
}

panStart

{
  pointerType,
  timeStamp,
  x,
  y,
}

pan

{
  initialTimeStamp,
  initialX,
  initialY,
  pointerType,
  previousTimeStamp,
  previousX,
  previousY,
  timeStamp,
  x,
  y,
}

panEnd

{
  initialTimeStamp,
  initialX,
  initialY,
  pointerType,
  timeStamp,
  x,
  y,
}

tap

{
  pointerType,
  timeStamp,
  x,
  y,
}

Keywords

FAQs

Last updated on 17 Nov 2018

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc