Skip to content
A tiny single-finger tap and swipe library.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
README.md
index.js
package-lock.json
package.json

README.md

rosin

A tiny single-finger tap and swipe library. Works with touch and/or mouse events. 700 bytes gzipped.

Install

npm i rosin --save

Usage

import rosin from 'rosin'

const swiper = rosin(document.body)

swiper.on('tap', ({ x, y }, e) => {})
swiper.on('mouseup', ({ x, y }, e) => {})
swiper.on('mousedown', ({ x, y }, e) => {})

/** Fired on every tick */
swiper.on('drag', ({ x, y }, e) => {})
swiper.on('dragLeft', ({ x, y }, e) => {})
swiper.on('dragRight', ({ x, y }, e) => {})
swiper.on('dragUp', ({ x, y }, e) => {})
swiper.on('dragDown', ({ x, y }, e) => {})

/** Fired once on each swipe */
swiper.on('left', ({ x, y }, e) => {})
swiper.on('right', ({ x, y }, e) => {})
swiper.on('up', ({ x, y }, e) => {})
swiper.on('down', ({ x, y }, e) => {})

Each emitter also returns a function to destroy itself:

const tapListener = swiper.on('tap', () => {})

tapListener() // destroy listener

To destroy the entire instance:

swiper.destroy()

License

MIT License © Eric Bailey

You can’t perform that action at this time.