swipyjs

0.0.6 • Public • Published

Swipy

A lightweight JavaScript library for simple touch swipe gesture events.

Installation

NPM

npm i swipyjs

Yarn

yarn add swipyjs

Usage

Define Swipy event listeners by calling on(event, callback):

let swipy = new Swipy(document.getElementById('swipy-container'));

swipy.on('swipeleft', function(event, touches) {
    console.log('Swiped to the left!');
});

The callback function receives two parameters:

  • event: the last native touchmove event that was triggered.
  • touches: an object containing the current touch coordinates:
{
    down: {x: null, y: null},
    up: {x: null, y: null},
    diff: {x: null, y: null}
}

Methods

swipy.on(event, callback)

Registers a new Swipy event listener.

Available events are:

  • swipetop
  • swiperight
  • swipebottom
  • swipeleft

swipy.bind()

Adds the native event listeners used by the library.

swipy.unbind()

Removes the native event listeners used by the library.

swipy.trigger(listener, event)

Manually triggers a defined Swipy event.

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.0.69latest

Version History

VersionDownloads (Last 7 Days)Published
0.0.69
0.0.50
0.0.40
0.0.30
0.0.20
0.0.10

Package Sidebar

Install

npm i swipyjs

Weekly Downloads

9

Version

0.0.6

License

MIT

Unpacked Size

12.4 kB

Total Files

7

Last publish

Collaborators

  • voidgraphics
  • nyratas