0.6.0 • Published 2 years ago
react-native-circle-animation-list v0.6.0
Preview
react-native-circle-animation-list
Getting started
$ npm install @react-native-circle-animation-list
Requirements
Before installing react-native-circle-animation-list
, it is necessary to install its dependent libraries.
Steps 1:
react-native-gesture-handler
react-native-gesture-handler is a dependency for this package that you'll need to add to your project. To install, run the following commands:
npm i react-native-gesture-handler
cd ios && pod install
Steps 2:
react-native-reanimated
react-native-reanimated is a dependency for this package that you'll need to add to your project. To install, run the following commands:
npm i react-native-reanimated
,Add into babel.config.js file: plugins: ['react-native-reanimated/plugin']
cd ios && pod install
Steps 3:
Shopify/flash-list
Shopify/flash-list is a dependency for this package that you'll need to add to your project. To install, run the following commands:
npm i @shopify/flash-list
,cd ios && pod install
Steps 4:
react-native-reanimated-carousel
react-native-reanimated-carousel is a dependency for this package that you'll need to add to your project. To install, run the following commands:
npm i react-native-reanimated-carousel
,cd ios && pod install
Usage
Vertical circle-animation-list
import CircleAnimationList from 'react-native-circle-animation-list';
const renderHorizontalSlider = (item, index) => {
return (
<View style={styles.container}>
<View style={styles.circle}>
<Text style={styles.txt}>{index}</Text>
</View>
</View>
);
};
const onEndReached = () => {
console.log('=== onEndReached ===');
};
const renderFooterLoader = () => {
console.log('=== renderFooterLoader ===');
};
return (
<View style={{flex: 1}}>
<CircleAnimationList
data={feed}
extraData={true}
isHorizontalArray={false}
verticalAnimation={'fast'}
onEndReached={onEndReached}
horizontalAnimation={500}
horizontalListInLoop={true}
verticalScrollEnabled={true}
horizontalScrollEnabled={true}
showsVerticalScrollIndicator={false}
listFooterComponent={renderFooterLoader}
renderItem={(item, index) => renderHorizontalSlider(item, index)}
marginTopForFirstIndex={Responsive.heightPercentageToDP(35)}
verticalListRef={ref => console.log(ref)}
horizontalListRef={ref => console.log(ref)}
verticalCurrentIndex={value => console.log('verticalIndex =>', value)}
horizontalCurrentIndex={value =>
console.log('horizontalIndex =>', value)
}
/>
</View>
);
}
const feed = [
{
id: 774,
},
{
id: 774,
},
{
id: 774,
},
{
id: 774,
},
];
const styles = StyleSheet.create({
container: {
alignItems: 'center',
justifyContent: 'center',
marginLeft: 100,
width: 350,
backgroundColor: 'red',
},
circle: {
alignItems: 'center',
justifyContent: 'center',
backgroundColor: 'black',
width: 300,
height: 300,
borderRadius: 150,
},
txt: {color: 'red', fontSize: 35},
});
Vertical and Horizontal circle-animation-list
import CircleAnimationList from 'react-native-circle-animation-list';
const renderHorizontalSlider = (item, index) => {
return (
<View style={styles.container}>
<View style={styles.circle}>
<Text style={styles.txt}>{index}</Text>
</View>
</View>
);
};
const onEndReached = () => {
console.log('=== onEndReached ===');
};
const renderFooterLoader = () => {
console.log('=== renderFooterLoader ===');
};
return (
<View style={{flex: 1}}>
<CircleAnimationList
data={feed}
extraData={true}
secondArrayName={'userSharedTracks'}
isHorizontalArray={true}
verticalAnimation={'fast'}
onEndReached={onEndReached}
horizontalAnimation={500}
horizontalListInLoop={true}
verticalScrollEnabled={true}
horizontalScrollEnabled={true}
showsVerticalScrollIndicator={false}
listFooterComponent={renderFooterLoader}
renderItem={(item, index) => renderHorizontalSlider(item, index)}
marginTopForFirstIndex={Responsive.heightPercentageToDP(35)}
verticalListRef={ref => console.log(ref)}
horizontalListRef={ref => console.log(ref)}
verticalCurrentIndex={value => console.log('verticalIndex =>', value)}
horizontalCurrentIndex={value =>
console.log('horizontalIndex =>', value)
}
/>
</View>
);
}
const feed = [
{
id: 774,
userSharedTracks: [
{
id: 774,
},
{
id: 774,
},
{
id: 774,
},
],
},
{
id: 774,
userSharedTracks: [
{
id: 774,
},
{
id: 774,
},
{
id: 774,
},
],
},
{
id: 774,
userSharedTracks: [
{
id: 774,
},
{
id: 774,
},
{
id: 774,
},
],
},
{
id: 774,
userSharedTracks: [
{
id: 774,
},
{
id: 774,
},
{
id: 774,
},
],
},
];
const styles = StyleSheet.create({
container: {
alignItems: 'center',
justifyContent: 'center',
marginLeft: 100,
width: 350,
backgroundColor: 'red',
},
circle: {
alignItems: 'center',
justifyContent: 'center',
backgroundColor: 'black',
width: 300,
height: 300,
borderRadius: 150,
},
txt: {color: 'red', fontSize: 35},
});
Note:
There is no any difference between Vertical circle-animation-list and Vertical and Horizontal circle-animation-list.
- Vertical circle-animation-list only have to pass isHorizontalArray={false}
- use Vertical & Horizontal circle-animation-list isHorizontalArray={true} and secondArrayName={'userSharedTracks'}
Basic properties
Props | type | description | required | ||
---|---|---|---|---|---|
data | Array | Provide array to library | 'required' | ||
isHorizontalArray | Boolean | true = vertical & horizontal list, false = only vertical list | 'required' | ||
renderItem | func | renderItem | 'Not necessary' | ||
secondArrayName | String | when need horizontal list provide horizontal array name | 'required' | ||
marginTopForFirstIndex | number | first item margin from top | 'not required' | ||
extraData | Boolean | re-render the list | 'Not necessary' | ||
verticalAnimation | String | 'fast' or 'normal' | 'Not necessary' | ||
onEndReached | func | function is trigger when list reached at Bottom | 'Not necessary' | ||
horizontalAnimation | number | Animation duration | 800 | ||
horizontalListInLoop | Boolean | horizontal list circle loop | true | false | |
verticalScrollEnabled | Boolean | if true it's lock vertical scrolling | 'Not necessary' | ||
horizontalScrollEnabled | Boolean | if true it's lock horizontal scrolling | 'Not necessary' | ||
listFooterComponent | func | Footer loader | 'Not necessary' | ||
verticalListRef | func | provide vertical list refrence | 'Not necessary' | ||
horizontalListRef | func | provide horizontal list refrence | 'Not necessary' | ||
verticalCurrentIndex | func | vertical current index | 'Not necessary' | ||
horizontalCurrentIndex | func | horizontal current index | 'Not necessary' | ||
showsVerticalScrollIndicator | Boolean | true or false | 'Not necessary' |