Socket
Socket
Sign inDemoInstall

vanilla-swipe

Package Overview
Dependencies
0
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    vanilla-swipe

Tiny vanilla JS library to detect swipe direction.


Version published
Weekly downloads
39K
increased by11.62%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

vanilla-swipe

Tiny vanilla JS library to detect swipe direction.

Build Status npm version covarage

Types

type ConstructorProps = {
  element?: HTMLElement | null;
  rotationAngle?: number | 0;
  delta?: number | 10; // minimum distance to the start of the swiping (px)
  mouseTrackingEnabled?: boolean | false;
  touchTrackingEnabled?: boolean | true;
  preventDefaultTouchmoveEvent?: boolean | false; // stop the browser scrolling while swiping
  onSwiping?: EventHandler;
  onSwiped?: EventHandler;
  onTap?: (e: Event) => void;
};

type EventHandler = {
  (
    e: Event,
    deltaX: number,
    deltaY: number,
    absX: number,
    absY: number,
    duration: number,
    velocity: number
  ): void;
};

Methods

  • init(): void
  • update(options: ConstructorProps): void
  • destroy(): void

Install

npm install vanilla-swipe

Examples

import VanillaSwipe from 'vanilla-swipe';

const VS = new VanillaSwipe({
  element: document.getElementById('some-id');
  onSwiping: handler,
  onSwiped: handler,
  mouseTrackingEnabled: true,
});

VS.init();

function handler() {
  console.log(...arguments); // -> Event, deltaX, deltaY, absX, absY, duration, velocity
}

Tests

npm test

Coverage

npm run testWithCoverage

Keywords

FAQs

Last updated on 19 Dec 2019

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