Gathering detailed insights and metrics for easy-swipe-view
Gathering detailed insights and metrics for easy-swipe-view
Gathering detailed insights and metrics for easy-swipe-view
Gathering detailed insights and metrics for easy-swipe-view
SwipeView is an npm package that lets you create swipeable views that can be easily used in React Native projects.
npm install easy-swipe-view
Typescript
Module System
Node Version
NPM Version
38.4
Supply Chain
53
Quality
66.5
Maintenance
50
Vulnerability
94.1
License
JavaScript (46.79%)
TypeScript (27.98%)
Java (25.23%)
Total Downloads
4,476
Last Day
6
Last Week
30
Last Month
184
Last Year
2,090
19 Commits
1 Watching
1 Branches
1 Contributors
Latest Version
1.1.15
Package Id
easy-swipe-view@1.1.15
Unpacked Size
27.31 kB
Size
6.17 kB
File Count
15
NPM Version
9.2.0
Node Version
16.13.0
Publised On
04 Apr 2023
Cumulative downloads
Total Downloads
Last day
50%
6
Compared to previous day
Last week
-67.4%
30
Compared to previous week
Last month
1.1%
184
Compared to previous month
Last year
-12.4%
2,090
Compared to previous year
2
A simple and easy-to-use swipeable list component for React Native
projects, built with Reanimated v2 and react-native-gesture-handler.
Reanimated
v3Expo
.TypeScript
Buttons
components for swipe actionsFirst, make sure you have installed react-native-reanimated v3 and react-native-gesture-handler in your project: Then,
npm install easy-swipe-view
or
yarn add easy-swipe-view
or
pnpm add easy-swipe-view
SwipeView
component and the EasySwipe
context:1import { SwipeView, EasySwipe, LeftButton, RightButton } from 'easy-swipe-view';
Note 💡 If you are not going to use the component inside a scrollable element, skip this step.
1<EasySwipe.Provider value={ref}> 2 <FlatList 3 ref={ref} 4 ... 5 /> 6</EasySwipe.Provider>
1const MyLeftButtonComponent = () => ( 2 <LeftButton 3 onPress={leftButtonAction} 4 width={100} 5 backgroundColor="#ff0015" 6 > 7 <Octicons name="trash" size={22} color={"#fff"} /> 8 </LeftButton> 9); 10 11const MyRightButtonComponent = () => ( 12 <RightButton 13 onPress={rightButtonAction} 14 width={100} 15 backgroundColor="#0088ff" 16 > 17 <Octicons name="archive" size={22} color={"#fff"} /> 18 </RightButton> 19);
1<SwipeView 2 ref={swipeRef} 3 LeftButton={MyLeftButtonComponent} //If you leave it blank, it will be disabled. 4 RightButton={MyRightButtonComponent} //If you leave it blank, it will be disabled. 5 leftOffset={100} 6 rightOffset={100} 7 maxLeft={150} 8 maxRight={150} 9 onLeftSwipe={() => console.log("On Swipe!")} 10 onRightSwipe={() => console.log("On Swipe!")} 11 onSwipe={(position) => console.log(position)} 12> 13 <View 14 style={{ 15 width: '100%', 16 backgroundColor: 'gray', 17 paddingTop: 6, 18 paddingBottom: 6, 19 paddingLeft: 4, 20 paddingRight: 4, 21 alignItems: 'center' 22 }} 23 > 24 <Text style={{color: "#030303"}}>Swipe me!</Text> 25 </View> 26</SwipeView>
If you want to reset the position by outside intervention;
1<TouchableHighlight onPress={() => swipeRef.current.resetPosition()}> 2 <Text>Reset</Text> 3</TouchableHighlight>
1import { SwipeList } from 'easy-swipe-view';
1<SwipeList 2 LeftButton={MyLeftButtonComponent} 3 RightButton={MyRightButtonComponent} 4 leftOffset={myLeftOffset} 5 rightOffset={myRightOffset} 6 maxLeft={150} 7 maxRight={150} 8 onLeftSwipe={() => console.log("On Swipe!")} 9 onRightSwipe={() => console.log("On Swipe!")} 10 onSwipe={(position) => console.log(position)} 11 data={yourData} 12 renderItem={({item}) => ( 13 <View 14 style={{ 15 width: '100%', 16 backgroundColor: 'gray', 17 paddingTop: 6, 18 paddingBottom: 6, 19 paddingLeft: 4, 20 paddingRight: 4, 21 alignItems: 'center' 22 }} 23 > 24 <Text style={{color: "#030303"}}>{item.title}</Text> 25 </View> 26 )} 27 keyExtractor={(item, index) => index.toString()} 28/>
This file contains the props documentation for the SwipeView
, Buttons
, and SwipeList
components.
Prop | Type | Default | Description |
---|---|---|---|
LeftButton | Component | null | The component to be rendered when swiping to the right. If not provided, left swipe will be disabled. |
RightButton | Component | null | The component to be rendered when swiping to the left. If not provided, right swipe will be disabled. |
leftOffset | number | 100 | The offset required to trigger a left swipe action. |
rightOffset | number | 100 | The offset required to trigger a right swipe action. |
maxLeft | number | 150 | The maximum distance the item can be swiped to the right. |
maxRight | number | 150 | The maximum distance the item can be swiped to the left. |
onLeftSwipe | (value: number) => void | null | A callback function to be called when a left swipe action is triggered. |
onRightSwipe | (value: number) => void | null | A callback function to be called when a right swipe action is triggered. |
onSwipe | (value: number) => void | null | A callback function to be called when the item is being swiped. |
children | React.ReactNode | null | The content of the SwipeView component. |
Prop | Type | Default | Description |
---|---|---|---|
onPress | () => void | () => {} | The callback function to be called when the button is pressed. |
width | number | 100 | The width of the button component. |
backgroundColor | string | '#ff0015' for LeftButton, '#0088ff' for RightButton | The background color of the button component. |
underlayColor | string | '#b00412' for LeftButton, '#0077ff' for RightButton | The background color of the button component for active. |
style | ViewStyle | {} | Additional styles for the button component. |
children | React.ReactNode | <></> | The content of the button component. |
...props | any | - | Other props to be passed down to the TouchableHighlight component. |
Prop | Type | Default | Description |
---|---|---|---|
...flatListProps | any | - | All other props available for the FlatList component. |
LeftButton | Component | null | The component to be rendered when swiping to the right. If not provided, left swipe will be disabled. |
RightButton | Component | null | The component to be rendered when swiping to the left. If not provided, right swipe will be disabled. |
leftOffset | number | 100 | The offset required to trigger a left swipe action. |
rightOffset | number | 100 | The offset required to trigger a right swipe action. |
maxLeft | number | 150 | The maximum distance the item can be swiped to the right. |
maxRight | number | 150 | The maximum distance the item can be swiped to the left. |
onLeftSwipe | (value: number) => void | null | A callback function to be called when a left swipe action is triggered. |
onRightSwipe | (value: number) => void | null | A callback function to be called when a right swipe action is triggered. |
onSwipe | (value: number) => void | null | A callback function to be called when the item is being swiped. |
renderItem | ({item, index}) => JSX.Element | null | A function that returns the component to be rendered for each item in the list. Must be wrapped with SwipeView . |
Please refer to the examples provided in the repository for detailed usage instructions.
No vulnerabilities found.
No security vulnerabilities found.