Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
swiped-events
Advanced tools
A 0.7k script that adds swipe events to the DOM for touch enabled devices
A 0.7k script that adds swiped-left
, swiped-right
, swiped-up
and swiped-down
events to the DOM using CustomEvent and pure JS. Based on the StackOverflow thread Detect a finger swipe through JavaScript on the iPhone and Android
Add swiped-events.min.js to your page and start listening for swipe events. Events bubble, so you can addEventListener
at document level, or on individual elements.
document.addEventListener('swiped-left', function(e) {
console.log(e.target); // element that was swiped
console.log(e.detail); // event data { dir: 'left', xStart: 196, xEnd: 230, yStart: 196, yEnd: 4 }
});
document.addEventListener('swiped-right', function(e) {
console.log(e.target); // element that was swiped
console.log(e.detail); // event data { dir: 'right', xStart: 196, xEnd: 230, yStart: 196, yEnd: 4 }
});
document.addEventListener('swiped-up', function(e) {
console.log(e.target); // element that was swiped
console.log(e.detail); // event data { dir: 'up', xStart: 196, xEnd: 230, yStart: 196, yEnd: 4 }
});
document.addEventListener('swiped-down', function(e) {
console.log(e.target); // element that was swiped
console.log(e.detail); // event data { dir: 'down', xStart: 196, xEnd: 230, yStart: 196, yEnd: 4 }
});
You can optionally configure how swiped-events works using the following HTML attributes:
Attribute | Description | Type | Default |
---|---|---|---|
data-swipe-threshold | Number of pixels a user must move before swipe fires | integer | 20 |
data-swipe-timeout | Number of milliseconds from touchstart to touchend | integer | 500 |
data-swipe-ignore | If true, swipe events on this element are ignored | boolean | false |
If you do not provide any attributes, it assumes the following:
<div data-swipe-threshold="20"
data-swipe-timeout="500"
data-swipe-ignore="false">
Swiper, get swiping!
</div>
git checkout -b my-new-feature
git commit -m 'Add some feature'
git push origin my-new-feature
The project includes everything needed to tweak, including a node webserver. Run the following, then visit http://localhost:8080 in your browser.
You can test on a desktop using Device Mode in Google Chrome.
git clone https://github.com/john-doherty/swiped-events
cd swiped-events
npm install
npm start
To create a new version of the minified swiped-events.min.js file from source, tweak the version number in package.json
and run the following:
npm run build
If you find this useful, please star the repo. It helps me priorities which OSS issues to tackle first 🙌
For change-log, check releases.
Licensed under MIT License © John Doherty
FAQs
A 1k script that adds swipe events to the DOM for touch enabled devices
The npm package swiped-events receives a total of 7,074 weekly downloads. As such, swiped-events popularity was classified as popular.
We found that swiped-events demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.