Installations
npm install @jpweeks/touchsweep
Developer Guide
Typescript
Yes
Module System
CommonJS
Node Version
18.10.0
NPM Version
8.19.2
Score
71.3
Supply Chain
99.3
Quality
75.3
Maintenance
100
Vulnerability
100
License
Releases
Use passive event listeners for better web vitals
Published on 17 Oct 2023
Add move detection
Published on 16 Nov 2022
Use Rollup to build
Published on 01 Nov 2022
Migrate to TypeScript
Published on 30 Sept 2022
Mouse support
Published on 02 Mar 2022
TypeScript definitions
Published on 20 Apr 2021
Contributors
Languages
TypeScript (84.4%)
JavaScript (15.6%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
Download Statistics
Total Downloads
872
Last Day
2
Last Week
4
Last Month
19
Last Year
94
GitHub Statistics
10 Stars
713 Commits
6 Forks
3 Watching
1 Branches
4 Contributors
Bundle Size
2.76 kB
Minified
928.00 B
Minified + Gzipped
Sponsor this package
Package Meta Information
Latest Version
2.1.0
Package Id
@jpweeks/touchsweep@2.1.0
Unpacked Size
25.42 kB
Size
6.50 kB
File Count
7
NPM Version
8.19.2
Node Version
18.10.0
Total Downloads
Cumulative downloads
Total Downloads
872
Last day
0%
2
Compared to previous day
Last week
-55.6%
4
Compared to previous week
Last month
171.4%
19
Compared to previous month
Last year
-82.3%
94
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
TouchSweep
Super tiny vanilla JS module to detect swipe direction and trigger custom events accordingly.
Visitor stats
Code stats
Install
1npm i touchsweep
or
1yarn add touchsweep
Usage
1import TouchSweep from 'touchsweep'; 2 3const area = document.getElementById('swipe-area'); 4const data = { 5 value: 1 6}; 7const touchThreshold = 20; 8 9const touchSwipeInstance = new TouchSweep(area, data, touchThreshold); 10 11// Then listen for custom swipe events and do your magic: 12 13area.addEventListener('swipeleft', event => { 14 // You have swiped left 15 // Custom event data is located in event.detail 16}); 17 18area.addEventListener('swiperight', event => { 19 // You have swiped right 20 // Custom event data is located in event.detail 21}); 22 23area.addEventListener('swipedown', event => { 24 // You have swiped down 25 // Custom event data is located in event.detail 26}); 27 28area.addEventListener('swipeup', event => { 29 // You have swiped up 30 // Custom event data is located in event.detail 31}); 32 33area.addEventListener('tap', event => { 34 // You have tapped 35 // Custom event data is located in event.detail 36});
Options and default settings
The module constructor accepts three (3) arguments:
element
: A HTML Element. Default isdocument.body
eventData
: A plain JS object. Default is{}
threshold
: How many pixels to count until an event is fired. Default is 40
API
TouchSweep provides a minimal API for you to use.
The TouchSwipe
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 TouchSwipe
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:
1touchSwipeInstance.unbind();
In order to add all previously removed event listeners:
1touchSwipeInstance.bind();
Supported Browsers
Currently all evergreen browsers are supported.
Demo
There is a simple demo illustrating how the TouchSweep library works.
Check it out here
LICENSE
MIT
![Empty State](/_next/static/media/empty.e5fae2e5.png)
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
18 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
0 existing vulnerabilities detected
Reason
SAST tool is not run on all commits -- score normalized to 1
Details
- Warn: 1 commits out of 8 are checked with a SAST tool
Reason
Found 0/27 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/build.yml:1
- Info: no jobLevel write permissions found
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/scriptex/touchsweep/build.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/scriptex/touchsweep/build.yml/master?enable=pin
- Info: 0 out of 2 GitHub-owned GitHubAction dependencies pinned
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Score
4.4
/10
Last Scanned on 2025-02-03
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More