smart-swipe-controller
v0.1.3
Published
Helps trigger events on swipe
Downloads
1
Maintainers
Readme
smart-swipe-controller
Lib simple add additional tap events in HTML element
additional events:
- swipeLeft - swipe from right to left
- swipeRight - swipe from left to right
- swipeUp - swipe from bottom to top
- swipeDown - swipe from top to bottom
- tap - one tap
Usage
VIA NPM
npm install smart-swipe-controller
- Import controller to your project
import { SmartSwipeController } from "smart-swipe-controller";
- Add it to HTML element
new SmartSwipeController(HTML_Element);
Classic import method
Include SmartSwipeController and add additional events to HTML element
like this
- If you want include as a module
Copy file from this (or minify version) to your project folder
<script type="module"> import { SmartSwipeController } from "./smartSwipeController.esm.js"; new SmartSwipeController(HTML_Element, 30) </script>
- If you want include as iife-style (you need use global object
SSC
) Copy file from this (or minify version) to your project folder<script src="smartSwipeController.iife.js"></script> <script> new SSC.SmartSwipeController(HTML_Element, 30); </script>
Subscribe to additional events
HTML_Element.addEventListener("swipeleft", () => {
...
});
HTML_Element.addEventListener("swiperight", () => {
...
});
HTML_Element.addEventListener("swipeup", () => {
...
});
HTML_Element.addEventListener("swipedown", () => {
...
});
HTML_Element.addEventListener("tap", () => {
...
});