JavaScript Library For Handling Swipe Up/Down/Left/Right Events – basicSwipe.js

Category: Javascript | August 19, 2025
Authortaosapp
Last UpdateAugust 19, 2025
LicenseMIT
Tags
Views1,722 views
JavaScript Library For Handling Swipe Up/Down/Left/Right Events – basicSwipe.js

A basic touch gesture handling library that allows you to add swipeUp, swipeDown, swipeLeft, and swipeRight event listeners on any DOM elements.

How to use it:

1. Import the basicSwipe.js JavaScript library.

import basicSwipe from "./basicSwipe.js";

2. Add swipe event listeners to elements as follows:

const example = document.querySelector('.example'),
const detector = basicSwipe(example, "swipeUp", function(){
  // do something
});
const detector = basicSwipet(example, "swipeDown", function(){
  // do something
});
const detector = basicSwipe(example, "swipeLeft", function(){
  // do something
});
const detector = basicSwipe(example, "swipeRight", function(){
  // do something
});

3. Turn off or on the monitoring of gesture events:

detector.on();
detector.off();

Changelog:

v1.0.6 (08/19/2024)

  • add on/off & options

v1.0.4 (06/04/2024)

  • update to module

You Might Be Interested In:


Leave a Reply