![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
touchsweep
Advanced tools
Super tiny vanilla JS module to detect swipe direction and trigger custom events accordingly.
npm i touchsweep
or
yarn add touchsweep
import TouchSweep from 'touchsweep';
const area = document.getElementById('swipe-area');
const data = {
value: 1
};
const touchThreshold = 20;
const touchSweepInstance = new TouchSweep(area, data, touchThreshold);
// Then listen for custom swipe events and do your magic:
area.addEventListener('swipeleft', event => {
// You have swiped left
// Custom event data is located in `event.detail`
// Details about coordinates are also available under `event.detail`
});
area.addEventListener('swiperight', event => {
// You have swiped right
// Custom event data is located in `event.detail`
// Details about coordinates are also available under `event.detail`
});
area.addEventListener('swipedown', event => {
// You have swiped down
// Custom event data is located in `event.detail`
// Details about coordinates are also available under `event.detail`
});
area.addEventListener('swipeup', event => {
// You have swiped up
// Custom event data is located in `event.detail`
// Details about coordinates are also available under `event.detail`
});
area.addEventListener('swipemove', event => {
// You are swiped continuously
// Custom event data is located in `event.detail`
// Details about coordinates are also available under `event.detail`
});
area.addEventListener('tap', event => {
// You have tapped
// Custom event data is located in `event.detail`
// Details about coordinates are also available under `event.detail`
});
The module constructor accepts three (3) arguments:
element
: A HTML Element. Default is document.body
eventData
: A plain JS object. Default is {}
threshold
: How many pixels to count until an event is fired. Default is 40TouchSweep provides a minimal API for you to use.
The TouchSweep
instance exposes two public methods which allow you to add or to remove all event listeners responsible for the module functionality.
This is useful in cases where you want to remove the TouchSweep
container/area from the DOM and prevent possible memory leaks by removing all event listeners related to this DOM element.
In order to remove all previously attached event listeners:
touchSweepInstance.unbind();
In order to add all previously removed event listeners:
touchSweepInstance.bind();
Currently all evergreen browsers are supported.
There is a simple demo illustrating how the TouchSweep library works.
Check the code here and the live demo here
TouchSweep
is written in Typescript and provides full Typescript support out of the box.
MIT
FAQs
Super tiny vanilla JS module to detect swipe direction
We found that touchsweep demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.