Security News
PyPI’s New Archival Feature Closes a Major Security Gap
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
react-easy-swipe
Advanced tools
The react-easy-swipe package is a lightweight React component that provides easy-to-use swipe detection for touch devices. It allows developers to handle swipe events such as swiping left, right, up, and down, making it useful for implementing features like carousels, sliders, and other touch-based interactions.
Swipe Detection
This feature allows you to detect swipe movements in different directions. The code sample demonstrates how to use the Swipe component to handle swipe left, swipe right, and swipe move events.
```jsx
import React from 'react';
import Swipe from 'react-easy-swipe';
class SwipeComponent extends React.Component {
onSwipeMove(position, event) {
console.log('Moved to:', position);
}
onSwipeLeft(event) {
console.log('Swiped left!');
}
onSwipeRight(event) {
console.log('Swiped right!');
}
render() {
return (
<Swipe
onSwipeMove={this.onSwipeMove}
onSwipeLeft={this.onSwipeLeft}
onSwipeRight={this.onSwipeRight}
>
<div style={{ width: '100%', height: '100px', background: 'lightgray' }}>
Swipe me!
</div>
</Swipe>
);
}
}
export default SwipeComponent;
```
react-swipeable is a React component that provides similar swipe detection capabilities. It offers more customization options and supports additional swipe events like swipe up and swipe down. Compared to react-easy-swipe, react-swipeable has a more extensive API and better documentation.
react-swipe is another alternative for handling swipe events in React. It is specifically designed for creating touch-enabled carousels and sliders. While it is more focused on carousel functionality, it can still be used for general swipe detection. It is slightly heavier than react-easy-swipe but offers more built-in features for carousel implementations.
Add swipe interactions to your react component.
http://leandrowd.github.io/react-easy-swipe/
To prevent scroll during swipe, return true from the handler passed to onSwipeMove
To allow mouse events to behave like touch, pass a prop allowMouseEvents
To prevent accidental swipes on scroll, pass a prop tolerance with the tolerance pixel as number.
npm install react-easy-swipe --save
import React, {Component} from 'react';
import ReactDOM from 'react-dom';
import Swipe from 'react-easy-swipe';
class MyComponent extends Component {
onSwipeStart(event) {
console.log('Start swiping...', event);
}
onSwipeMove(position, event) {
console.log(`Moved ${position.x} pixels horizontally`, event);
console.log(`Moved ${position.y} pixels vertically`, event);
}
onSwipeEnd(event) {
console.log('End swiping...', event);
}
render() {
const boxStyle = {
width: '100%',
height: '300px',
border: '1px solid black',
background: '#ccc',
padding: '20px',
fontSize: '3em'
};
return (
<Swipe
onSwipeStart={this.onSwipeStart}
onSwipeMove={this.onSwipeMove}
onSwipeEnd={this.onSwipeEnd}>
<div style={boxStyle}>Open the console and swipe me</div>
</Swipe>
);
}
}
ReactDOM.render(<MyComponent/>, document.getElementById('root'));
{
tagName: PropTypes.string,
className: PropTypes.string,
style: PropTypes.object,
children: PropTypes.node,
allowMouseEvents: PropTypes.bool,
onSwipeUp: PropTypes.func,
onSwipeDown: PropTypes.func,
onSwipeLeft: PropTypes.func,
onSwipeRight: PropTypes.func,
onSwipeStart: PropTypes.func,
onSwipeMove: PropTypes.func,
onSwipeEnd: PropTypes.func,
tolerance: PropTypes.number.isRequired
}
Please, feel free to contribute. You may open a bug, request a feature, submit a pull request or whatever you want!
FAQs
React easy swipe - Easy handler for common touch operations
The npm package react-easy-swipe receives a total of 213,550 weekly downloads. As such, react-easy-swipe popularity was classified as popular.
We found that react-easy-swipe 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
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
Research
Security News
Malicious npm package postcss-optimizer delivers BeaverTail malware, targeting developer systems; similarities to past campaigns suggest a North Korean connection.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.