Minimal JavaScript Library For Handling Touch Swipe Events – LC-Swiper

Category: Javascript | April 30, 2021
Author: LCweb-ita
Views Total: 34 views
Official Page: Go to website
Last Update: April 30, 2021
License: MIT

Preview:

Minimal JavaScript Library For Handling Touch Swipe Events – LC-Swiper

Description:

LC-Swiper is a tiny JavaScript library (ES6) designed for handling touch swipe events on given elements.

How to use it:

1. Import the JavaScript file lc-swiper.js into the document.

<script src="lc-swiper.min.js"></script>

2. Create a new instance of the LC-Swiper and determine the target element on which you want to detect touch swipe events.

<div id="targetContainer">
  <h2>Swipe here!</h2>
</div>
const swiper = new lc_swiper('#targetContainer');

3. Trigger a function every time you swipe on that element.

const swiper = new lc_swiper('#targetContainer', function(directions, $el){
      // do something
      // directions.top
      // directions.right
      // directions.bottom
      // directions.left
});

You Might Be Interested In:


Leave a Reply